-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
37 lines (33 loc) · 1.27 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nmattera <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/06 11:28:20 by nmattera #+# #+# */
/* Updated: 2022/05/21 15:57:48 by nmattera ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
while (n > 0)
{
if (*(unsigned char *)s1 != *(unsigned char *)s2)
return (*(unsigned char *)s1 - *(unsigned char *)s2);
s1++;
s2++;
n--;
}
return (0);
}
/*
#include <stdio.h>
#include <string.h>
int main()
{
printf("cop: %d\n", ft_memcmp("b", "bimbqm", 0));
printf("OG : %d", memcmp("b", "bimbqm", 0));
}
*/