-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcmp.c
31 lines (28 loc) · 1.19 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: brpereir <brpereir@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/15 06:25:14 by brpereir #+# #+# */
/* Updated: 2023/04/15 06:25:29 by brpereir ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *str1, const void *str2, size_t n)
{
unsigned char const *ss1;
unsigned char const *ss2;
size_t i;
i = 0;
ss1 = (unsigned char const *)str1;
ss2 = (unsigned char const *)str2;
while (i < n)
{
if (ss1[i] != ss2[i])
return (ss1[i] - ss2[i]);
i++;
}
return (0);
}