42-archive/libft/srcs/mem/ft_memcmp.c
2017-03-31 18:21:20 +02:00

28 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:30 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:44:21 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t i;
int cmp;
i = -1;
while (++i < n)
{
cmp = *(unsigned char *)s1++ - *(unsigned char *)s2++;
if (cmp)
return (cmp);
}
return (cmp);
}