diff --git a/ft_memcmp.c b/ft_memcmp.c index 3dea5f1..a5efbaa 100644 --- a/ft_memcmp.c +++ b/ft_memcmp.c @@ -1,10 +1,16 @@ #include "libft.h" -// int ft_memcmp(const void *s1, const void *s2, size_t n) -// { -// const unsigned char *s1_ptr; -// const unsigned char *s2_ptr; -// size_t i; +int ft_memcmp(const void *s1, const void *s2, size_t n) +{ + char *c1; + char *c2; + int i; -// while () -// } + c1 = (char *)s1; + c2 = (char *)s2; + i = 0; + while (i < n && c1[i] == c2[i]) + i++; + if (i == n) return (0); + return (c1[i] - c2[i]); +}