-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
41 lines (37 loc) · 1.3 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kyungkim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/21 04:27:42 by kyungkim #+# #+# */
/* Updated: 2024/11/21 04:53:43 by kyungkim ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned char *dest;
unsigned char *src;
dest = (unsigned char *) s1;
src = (unsigned char *) s2;
while (n > 0)
{
if (*dest != *src)
return (*dest - *src);
dest++;
src++;
n--;
}
return (0);
}
/*
int main(void)
{
char arr1[]="hi42kay";
char arr2[]="hi43kay";
printf("%d",ft_memcmp(arr1, arr2, 3));
printf("%d",memcmp(arr1, arr2, 4));
}
*/