-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memcmp.c
31 lines (28 loc) · 1.12 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kokaimov <kokaimov@student.42berlin.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/15 14:23:27 by kokaimov #+# #+# */
/* Updated: 2023/11/15 14:23:27 by kokaimov ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned char *d1;
unsigned char *d2;
d1 = (void *)s1;
d2 = (void *)s2;
while (n && *d1 == *d2)
{
d1++;
d2++;
n--;
}
if (n)
return (*d1 - *d2);
return (0);
}