feat: added ft_strcmp.c

This commit is contained in:
Zoëy Noort 2025-05-05 19:14:45 +02:00
parent 99f0ea3fec
commit 8ad0f35891
2 changed files with 13 additions and 0 deletions

View file

@ -3,6 +3,7 @@
# include <stdlib.h> # include <stdlib.h>
int ft_strcmp(const char *s1, const char *s2);
int ft_islower(int c); int ft_islower(int c);
int ft_isupper(int c); int ft_isupper(int c);
int ft_tolower(int c); int ft_tolower(int c);

12
srcs/ft_strcmp.c Normal file
View file

@ -0,0 +1,12 @@
#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
}