-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_memcmp.c
executable file
·31 lines (28 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
30
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rel-fila <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/16 13:45:24 by rel-fila #+# #+# */
/* Updated: 2022/10/16 13:55:23 by rel-fila ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *str1, const void *str2, size_t n)
{
unsigned char *s1;
unsigned char *s2;
s1 = (unsigned char *) str1;
s2 = (unsigned char *) str2;
while (n > 0)
{
if (*s1 > *s2 || *s1 < *s2)
return (*s1 - *s2);
s1++;
s2++;
n--;
}
return (0);
}