miniRT/libft/ft_memcmp.c
2025-05-31 19:08:53 +02:00

32 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vvobis <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/03 15:27:15 by vvobis #+# #+# */
/* Updated: 2024/04/09 19:21:02 by vvobis ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(void *s1, void const *s2, size_t n)
{
unsigned char *p1;
unsigned char *p2;
unsigned int i;
p1 = (unsigned char *)s1;
p2 = (unsigned char *)s2;
i = 0;
while (i < n)
{
if (p1[i] != p2[i])
return (p1[i] - p2[i]);
i++;
}
return (0);
}