-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
31 lines (28 loc) · 1.13 KB
/
ft_memcmp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bcaffere <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/04/24 16:57:28 by bcaffere #+# #+# */
/* Updated: 2021/04/24 17:22:50 by bcaffere ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
t_uch *u_s1;
t_uch *u_s2;
size_t i;
u_s1 = (t_uch *)s1;
u_s2 = (t_uch *)s2;
i = 0;
while (i < n)
{
if (u_s1[i] != u_s2[i])
return (u_s1[i] - u_s2[i]);
i++;
}
return (0);
}