/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memcmp.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: joelecle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:06:42 by joelecle #+# #+# */ /* Updated: 2020/02/14 17:06:42 by joelecle ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include int ft_memcmp(const void *s1, const void *s2, size_t n) { const unsigned char *s1_ptr; const unsigned char *s2_ptr; s1_ptr = (unsigned char*)s1; s2_ptr = (unsigned char*)s2; while (n) { if (*s1_ptr != *s2_ptr) return (*s1_ptr - *s2_ptr); s1_ptr++; s2_ptr++; n--; } return (0); }