-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memcmp.c
42 lines (38 loc) · 1.36 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: sramos <marvin@42.fr> +#+ */
/* +#+ */
/* Created: 2023/10/09 11:00:13 by sramos #+# #+# */
/* Updated: 2023/10/28 12:47:50 by sramos ######## odam.nl */
/* */
/* ************************************************************************** */
// #include <string.h>
// #include <stdio.h>
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t i;
const unsigned char *us1;
const unsigned char *us2;
us1 = s1;
us2 = s2;
i = 0;
while (i < n)
{
if (us1[i] != us2[i])
return (us1[i] - us2[i]);
i++;
}
return (0);
}
// int main(void)
// {
// char *s1 = "abc\0fhgf";
// char *s2 = "abc\0fhgfh";
// printf("%i\n", memcmp(s1, s2, 9));
// printf("%i", ft_memcmp(s1, s2, 9));
// return (0);
// }