-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
32 lines (29 loc) · 1.19 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: rishimot <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/06 10:12:00 by rishimot #+# #+# */
/* Updated: 2020/07/17 14:52:39 by rishimot ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned char *p;
unsigned char *q;
if (s1 == s2 || n == 0)
return (0);
p = (unsigned char *)s1;
q = (unsigned char *)s2;
while (n--)
{
if (*p != *q)
return (*p - *q);
p++;
q++;
}
return (0);
}