diff --git a/hdrs/libft.h b/hdrs/libft.h index 79effd4..8b65d36 100644 --- a/hdrs/libft.h +++ b/hdrs/libft.h @@ -3,6 +3,7 @@ # include +int ft_strcmp(const char *s1, const char *s2); int ft_islower(int c); int ft_isupper(int c); int ft_tolower(int c); diff --git a/srcs/ft_strcmp.c b/srcs/ft_strcmp.c new file mode 100644 index 0000000..333207b --- /dev/null +++ b/srcs/ft_strcmp.c @@ -0,0 +1,12 @@ +#include + +int ft_strcmp(const char *s1, const char *s2) +{ + while (*s1 && (*s1 == *s2)) // Continue while both are equal and non-null + { + s1++; + s2++; + } + + return (unsigned char)(*s1) - (unsigned char)(*s2); // Return the difference of the first non-matching characters +} \ No newline at end of file