You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

31 lines
1.2 KiB

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: emartine <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/07 19:17:31 by emartine #+# #+# */
/* Updated: 2017/11/07 19:17:32 by emartine ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned char *c1;
unsigned char *c2;
size_t i;
if (s1 == s2 || n == 0)
return (0);
c1 = (unsigned char *)s1;
c2 = (unsigned char *)s2;
i = 0;
while (i < n && c1[i] == c2[i])
i++;
if (i == n)
return (0);
return (c1[i] - c2[i]);
}