36 lines
1.2 KiB
C
36 lines
1.2 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* :::::::: */
|
||
|
/* ft_memcmp.c |o_o || | */
|
||
|
/* +:+ */
|
||
|
/* By: djonker <marvin@codam.nl> +#+ */
|
||
|
/* +#+ */
|
||
|
/* Created: 2020/11/01 08:41:32 by djonker #+# #+# */
|
||
|
/* Updated: 2023/02/28 15:22:59 by houtworm \___)=(___/ */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "../libft.h"
|
||
|
|
||
|
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
||
|
{
|
||
|
const unsigned char *p1;
|
||
|
const unsigned char *p2;
|
||
|
|
||
|
if (!s1 && !s2)
|
||
|
return (0);
|
||
|
if (!s1 || !s2)
|
||
|
return (1);
|
||
|
p1 = s1;
|
||
|
p2 = s2;
|
||
|
while (n)
|
||
|
{
|
||
|
if (*p1 != *p2)
|
||
|
return (*p1 - *p2);
|
||
|
p1++;
|
||
|
p2++;
|
||
|
n--;
|
||
|
}
|
||
|
return (0);
|
||
|
}
|