-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memncmp.c
29 lines (26 loc) · 1.18 KB
/
ft_memncmp.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* memncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dskrypny <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/11 21:37:34 by dskrypny #+# #+# */
/* Updated: 2017/11/18 14:25:50 by dskrypny ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memncmp(const void *s1, const void *s2, size_t n)
{
unsigned const char *str1;
unsigned const char *str2;
size_t i;
i = 0;
str1 = (unsigned const char *)s1;
str2 = (unsigned const char *)s2;
while (i < n && str1[i] == str2[i] && str1[i])
{
i++;
}
return (str1[i] - str2[i]);
}