-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strncmp.c
36 lines (33 loc) · 1.18 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
32
33
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lbones <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/30 18:59:01 by lbones #+# #+# */
/* Updated: 2021/04/30 17:57:44 by lbones ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *s1, const char *s2, size_t num)
{
size_t i;
size_t i1;
i = 0;
if (num < 1)
return (0);
while (num > 1 && *s1 == *s2 && *s1 && *s2)
{
num--;
s1++;
s2++;
}
i = *s1;
i1 = *s2;
if (i > i1)
return (1);
else if (i == i1)
return (0);
return (-1);
}