1
0
libft_new/ft_memcmp.c
Adam Joly 52e89b462c fclean
2023-11-08 12:47:17 +01:00

25 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 12:04:48 by adjoly #+# #+# */
/* Updated: 2023/11/08 12:16:47 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stddef.h>
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t i;
i = 0;
while (((unsigned char *)s1)[i] == ((unsigned char *)s2)[i] && i < n - 1)
i++;
return (((unsigned char *)s1)[i] - ((unsigned char *)s2)[i]);
}