-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
34 lines (31 loc) · 1.15 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abdsalah <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/27 12:16:27 by abdsalah #+# #+# */
/* Updated: 2024/08/31 13:20:24 by abdsalah ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
const unsigned char *x;
const unsigned char *y;
if (n == 0)
return (0);
if (s1 == s2)
return (0);
x = s1;
y = s2;
while (n--)
{
if (*x != *y)
return (*x - *y);
x++;
y++;
}
return (0);
}