-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memcmp.c
33 lines (30 loc) · 1.19 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mkhaing <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/16 11:31:42 by mkhaing #+# #+# */
/* Updated: 2024/06/27 01:53:56 by mkhaing ### ########.fr */
/* */
/* ************************************************************************** */
#include <byamc/byamc.h>
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t i;
const unsigned char *p1;
const unsigned char *p2;
i = 0;
p1 = (unsigned char *)s1;
p2 = (unsigned char *)s2;
while ((n > i) && (p1[i] == p2[i]))
{
i++;
}
if (i == n)
{
return (0);
}
return (p1[i] - p2[i]);
}