42_cube3D/libftx/libft/ft_memcmp.c
Camille Chauvet 537283e940 add: libftx
2023-04-26 11:02:44 +00:00

30 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/27 14:15:37 by cchauvet #+# #+# */
/* Updated: 2022/09/27 15:10:56 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned char *str1;
unsigned char *str2;
size_t i;
if (n == 0)
return (0);
str1 = (unsigned char *) s1;
str2 = (unsigned char *) s2;
i = 0;
while (str1[i] == str2[i] && i < n - 1)
i++;
return (str1[i] - str2[i]);
}