-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
52 lines (44 loc) · 1.44 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rgerdzhi <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/02 17:19:41 by rgerdzhi #+# #+# */
/* Updated: 2024/07/18 18:54:28 by rgerdzhi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned char *ptr1;
unsigned char *ptr2;
size_t i;
ptr1 = (unsigned char *)s1;
ptr2 = (unsigned char *)s2;
i = 0;
while (i < n)
{
if (ptr1[i] != ptr2[i])
return (ptr1[i] - ptr2[i]);
i++;
}
return (0);
}
/*
int main ()
{
char *str1;
char *str2;
int rslt;
int ctrl;
str1 = strdup("RAYA");
str2 = strdup("RAYA");
ctrl = memcmp(str1, str2, 6);
rslt = ft_memcmp(str1, str2, 6);
printf("ctrl : %d\n", ctrl);
printf("rslt : %d\n", rslt);
return(0);
}
*/