fillit/libft/ft_memcmp.c

26 lines
1.1 KiB
C
Raw Normal View History

2016-12-26 18:48:33 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 16:31:56 by gtertysh #+# #+# */
/* Updated: 2016/12/06 14:07:47 by gtertysh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
while ((int)n--)
{
if ((*(unsigned char *)s1 != *(unsigned char *)s2))
return (*(unsigned char *)s1 - *(unsigned char *)s2);
s1++;
s2++;
}
return (0);
}