33 lines
1.1 KiB
C
33 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_memcmp.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2015/11/24 20:13:47 by scebula #+# #+# */
|
|
/* Updated: 2015/11/24 20:19:34 by scebula ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
|
{
|
|
unsigned char *a;
|
|
unsigned char *b;
|
|
|
|
a = (unsigned char *)s1;
|
|
b = (unsigned char *)s2;
|
|
while (n > 0 && *a == *b)
|
|
{
|
|
a++;
|
|
b++;
|
|
n--;
|
|
}
|
|
if (n == 0)
|
|
return (0);
|
|
else
|
|
return (*a - *b);
|
|
}
|