30 lines
1.2 KiB
C
30 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_memcmp.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/09/27 14:15:37 by cchauvet #+# #+# */
|
|
/* Updated: 2022/09/27 15:10:56 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
|
{
|
|
unsigned char *str1;
|
|
unsigned char *str2;
|
|
size_t i;
|
|
|
|
if (n == 0)
|
|
return (0);
|
|
str1 = (unsigned char *) s1;
|
|
str2 = (unsigned char *) s2;
|
|
i = 0;
|
|
while (str1[i] == str2[i] && i < n - 1)
|
|
i++;
|
|
return (str1[i] - str2[i]);
|
|
}
|