-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strncmp.c
31 lines (28 loc) · 1.12 KB
/
ft_strncmp.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_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: esupatae <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/19 21:49:15 by esupatae #+# #+# */
/* Updated: 2019/09/19 21:49:17 by esupatae ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(char *s1, char *s2, size_t n)
{
size_t i;
i = 0;
while (*s1 && *s2 && i < n)
{
if (*s1 != *s2)
break ;
s1++;
s2++;
i++;
}
if (i == n)
return (0);
return (*(unsigned char*)s1 - *(unsigned char*)s2);
}