1
0
libft_new/mem/ft_memcmp.c

26 lines
1.1 KiB
C
Raw Normal View History

2023-11-08 12:47:17 +01:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
2024-02-04 15:11:02 +01:00
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
2023-11-08 12:47:17 +01:00
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 12:04:48 by adjoly #+# #+# */
2024-02-04 15:11:02 +01:00
/* Updated: 2024/02/04 14:36:46 by adjoly ### ########.fr */
2023-11-08 12:47:17 +01:00
/* */
/* ************************************************************************** */
2024-02-04 15:11:02 +01:00
#include "../libft.h"
2023-11-08 12:47:17 +01:00
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t i;
i = 0;
2023-11-09 18:28:02 +01:00
if (n == 0)
return (0);
2023-11-08 12:47:17 +01:00
while (((unsigned char *)s1)[i] == ((unsigned char *)s2)[i] && i < n - 1)
i++;
return (((unsigned char *)s1)[i] - ((unsigned char *)s2)[i]);
}