diff --git a/lib/libft/libft.h b/lib/libft/libft.h index 56a9638..4639da7 100644 --- a/lib/libft/libft.h +++ b/lib/libft/libft.h @@ -35,6 +35,7 @@ size_t ft_strlcat(char *dst, const char *src, size_t dstsize); char *ft_strchr(const char *s, int c); char *ft_strrchr(const char *s, int c); int ft_strncmp(const char *s1, const char *s2, size_t n); +int ft_strcmp(const char *s1, const char *s2); char *ft_strnstr(const char *haystack, const char *needle, size_t len); char *ft_substr(const char *s, unsigned int start, size_t len); char *ft_strdup(const char *s1); diff --git a/lib/libft/srcs/str/ft_strcmp.c b/lib/libft/srcs/str/ft_strcmp.c new file mode 100644 index 0000000..3a69ecf --- /dev/null +++ b/lib/libft/srcs/str/ft_strcmp.c @@ -0,0 +1,11 @@ +#include "../../libft.h" + +int ft_strcmp(const char *s1, const char *s2) +{ + while (*s1 && *s2 && (*s1 == *s2)) + { + s1++; + s2++; + } + return ((unsigned char) *s1 - (unsigned char) *s2); +}