/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memcmp.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: pbonilla +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/10/29 12:23:50 by pbonilla #+# #+# */ /* Updated: 2021/01/29 13:09:55 by pbonilla ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" int ft_memcmp(const void *s1, const void *s2, size_t n) { unsigned char *ss1; unsigned char *ss2; unsigned int i; ss1 = (unsigned char *)s1; ss2 = (unsigned char *)s2; i = -1; if (n == 0) return (0); while (++i < n) { if (ss1[i] != ss2[i]) return (ss1[i] - ss2[i]); } return (0); }