feat: added ft_strcmp.c
This commit is contained in:
parent
99f0ea3fec
commit
8ad0f35891
2 changed files with 13 additions and 0 deletions
|
|
@ -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
12
srcs/ft_strcmp.c
Normal 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
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue