-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memcmp.c
42 lines (35 loc) · 1.47 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tauer <tauer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/13 13:56:32 by tauer #+# #+# */
/* Updated: 2023/11/13 13:56:32 by tauer ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *ptr1, const void *ptr2, size_t size)
{
size_t i;
i = 0;
while (i < size)
{
if (((unsigned char *)ptr1)[i] != ((unsigned char *)ptr2)[i])
return (((unsigned char *)ptr1)[i] - ((unsigned char *)ptr2)[i]);
i++;
}
return (0);
}
// int ft_memcmp(const void *ptr1, const void *ptr2, size_t size)
// {
// return (ft_strncmp((const char *)ptr1, (const char *)ptr2, size));
// }
// int main(void)
// {
// char s[] = {-128, 0, 127, 0};
// char sCpy[] = {-128, 0, 127, 0};
// printf("difference ascii : %d\n", ft_memcmp(s, sCpy, 4));
// return (0);
// }