-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memcmp.c
33 lines (30 loc) · 1.22 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
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ohachim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/10 01:06:59 by ohachim #+# #+# */
/* Updated: 2018/10/19 19:43:10 by ohachim ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t stp;
const char *dup1;
const char *dup2;
stp = 1;
dup1 = (const char*)s1;
dup2 = (const char*)s2;
if (n == 0)
return (0);
while (*dup1 == *dup2 && stp < n && s1 && s2)
{
dup1++;
dup2++;
stp++;
}
return ((unsigned char)*dup1 - (unsigned char)*dup2);
}