/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memcmp.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/10/03 13:37:06 by mcolonna #+# #+# */ /* Updated: 2023/10/09 12:00:22 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" int ft_memcmp(const void *s1, const void *s2, size_t n) { size_t i; if (n == 0) return (0); i = 0; while (i < n - 1 && ((unsigned char *)s1)[i] == ((unsigned char *)s2)[i]) i++; return (((unsigned char *)s1)[i] - ((unsigned char *)s2)[i]); }