-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
31 lines (28 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oelkhiar <oelkhiar@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/14 12:02:03 by oelkhiar #+# #+# */
/* Updated: 2022/11/20 12:11:46 by oelkhiar ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned char *st;
unsigned char *sy;
size_t i;
st = (unsigned char *)s1;
sy = (unsigned char *)s2;
i = 0;
while (i < n)
{
if (st[i] != sy[i])
return (st[i] - sy[i]);
i++;
}
return (0);
}