Files
mmoat/lib/libft/srcs/mem/ft_memcmp.c
gazhonsepaskwa 09c2cb5b3e base struct
2025-01-13 13:21:53 +01:00

29 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/14 11:54:32 by nalebrun #+# #+# */
/* Updated: 2024/11/25 16:15:04 by nalebrun ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t i;
const unsigned char *ps1;
const unsigned char *ps2;
ps1 = (const unsigned char *)s1;
ps2 = (const unsigned char *)s2;
i = -1;
while (++i < n)
if (ps1[i] != ps2[i])
return (ps1[i] - ps2[i]);
return (0);
}