/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memcmp.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/04/06 16:55:25 by tmaze #+# #+# */ /* Updated: 2018/04/06 17:27:15 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" int ft_memcmp(const void *s1, const void *s2, size_t n) { size_t i; int diff; unsigned char *str1; unsigned char *str2; i = 0; str1 = (unsigned char*)s1; str2 = (unsigned char*)s2; diff = str1[0] - str2[0]; while (diff == 0 && ++i < n) diff = str1[i] - str2[i]; return (diff); }