Archived
1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
libft/ft_memcmp.c
2023-11-09 18:28:02 +01:00

27 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 12:04:48 by adjoly #+# #+# */
/* Updated: 2023/11/09 14:06:17 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;
if (n == 0)
return (0);
while (((unsigned char *)s1)[i] == ((unsigned char *)s2)[i] && i < n - 1)
i++;
return (((unsigned char *)s1)[i] - ((unsigned char *)s2)[i]);
}