29 lines
1.1 KiB
C
29 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_memcmp.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tosuman <timo42@proton.me> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/05/22 16:44:15 by tosuman #+# #+# */
|
|
/* Updated: 2023/06/02 20:03:03 by tischmid ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stddef.h>
|
|
|
|
int ft_memcmp(void const *s1, void const *s2, size_t n)
|
|
{
|
|
unsigned char *us1;
|
|
unsigned char *us2;
|
|
|
|
us1 = (unsigned char *) s1;
|
|
us2 = (unsigned char *) s2;
|
|
if (!n)
|
|
return (0);
|
|
while (n--)
|
|
if (*us1++ != *us2++)
|
|
return (*--us1 - *--us2);
|
|
return (0);
|
|
}
|