-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
executable file
·30 lines (27 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmuteba <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/01/19 08:31:21 by mmuteba #+# #+# */
/* Updated: 2018/07/06 16:05:06 by mmuteba ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
const unsigned char *p_s1;
const unsigned char *p_s2;
p_s1 = s1;
p_s2 = s2;
while (n--)
{
if (*p_s1 != *p_s2)
return (*p_s1 - *p_s2);
p_s1++;
p_s2++;
}
return (0);
}