31 lines
1.2 KiB
C
31 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_memcmp.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: rzy <ry@student.42angouleme.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2026/08/23 23:24:25 by rzy #+# #+# */
|
|
/* Updated: 2026/08/23 23:26:32 by rzy ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
#include "libft.h"
|
|
|
|
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
|
{
|
|
unsigned char *s1_ptr;
|
|
unsigned char *s2_ptr;
|
|
size_t i;
|
|
|
|
s1_ptr = (unsigned char *)s1;
|
|
s2_ptr = (unsigned char *)s2;
|
|
i = 0;
|
|
while (i < n)
|
|
{
|
|
if (s1_ptr[i] != s2_ptr[i])
|
|
return (s1_ptr[i] - s2_ptr[i]);
|
|
++i;
|
|
}
|
|
return (0);
|
|
}
|