blob: 39fbdf6c78ba534966913ba6daa96836a7028cf9 (
plain)
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: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:06:42 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:06:42 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <stddef.h>
int
ft_memcmp(const void *s1, const void *s2, size_t n)
{
const unsigned char *s1_ptr;
const unsigned char *s2_ptr;
s1_ptr = (unsigned char*)s1;
s2_ptr = (unsigned char*)s2;
while (n)
{
if (*s1_ptr != *s2_ptr)
return (*s1_ptr - *s2_ptr);
s1_ptr++;
s2_ptr++;
n--;
}
return (0);
}
|