-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memcmp.c
executable file
·32 lines (29 loc) · 1.23 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
32
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/18 14:52:21 by akharrou #+# #+# */
/* Updated: 2019/03/04 13:17:20 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
#include "../Includes/string_42.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned char *s1_chr_p;
unsigned char *s2_chr_p;
if (n > 0)
{
s1_chr_p = (unsigned char *)s1;
s2_chr_p = (unsigned char *)s2;
while (--n > 0 && *s1_chr_p == *s2_chr_p)
{
++s1_chr_p;
++s2_chr_p;
}
return ((*s1_chr_p) - (*s2_chr_p));
}
return (0);
}