libft/src/memory/ft_memcmp.c

32 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: o_ :::::: ::: */
/* ft_memcmp.c :+: / :+::+: :+: */
/* +:+ > +:++:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#++#++:++#++ */
/* +#+ +#+#+ +#++#+ +#+ \o/ */
/* Created: 2024/10/10 17:00:22 by whaffman #+#+# #+#+# #+# #+# | */
/* Updated: 2024/10/10 17:00:22 by whaffman ### ### ### ### / \ */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned char *str1;
unsigned char *str2;
size_t i;
str1 = (unsigned char *)s1;
str2 = (unsigned char *)s2;
i = 0;
while (i < n)
{
if (str1[i] != str2[i])
return (str1[i] - str2[i]);
i++;
}
return (0);
}