libft/srcs/ft_strcmp.c

12 lines
No EOL
311 B
C

#include <stddef.h>
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
}