-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
29 lines (26 loc) · 1.16 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lpires-n <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/03 04:00:29 by lpires-n #+# #+# */
/* Updated: 2022/06/08 00:45:37 by lpires-n ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t i;
unsigned char *ss1;
unsigned char *ss2;
i = 0;
ss1 = (unsigned char *)s1;
ss2 = (unsigned char *)s2;
if (n == 0)
return (0);
while (ss1[i] == ss2[i] && --n)
i++;
return (ss1[i] - ss2[i]);
}