maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
ft_strcmp.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* ft_strcmp.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: rmikhayl <rmikhayl@student.42london.c +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2023/12/17 17:25:26 by rmikhayl #+# #+# */
9/* Updated: 2023/12/17 17:25:26 by rmikhayl ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "libft.h"
14
15/* *************************** ft_strncmp *********************************** */
16/* Compares two text strings, 's1' and 's2' */
17/* returning an integer value indicating their relationship. */
18/* */
19/* In layman's terms: It's like comparing the beginnings of two sentences */
20/* to see if they are the same or which comes first in the dictionary. If */
21/* something's different, it returns a result */
22/* ************************************************************************** */
23
24int ft_strcmp(const char *s1, const char *s2)
25{
26 while (*s1 != '\0' || *s2 != '\0')
27 {
28 if (*s1 != *s2)
29 return ((unsigned char)*s1 - (unsigned char)*s2);
30 s1++;
31 s2++;
32 }
33 return (0);
34}
int ft_strcmp(const char *s1, const char *s2)
Definition ft_strcmp.c:24