-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strncmp.c
35 lines (32 loc) · 1.21 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mdenys <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/29 12:22:15 by mdenys #+# #+# */
/* Updated: 2020/11/05 17:52:29 by mdenys ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *s1, const char *s2, size_t a)
{
unsigned int i;
unsigned char *d;
unsigned char *s;
d = (unsigned char *)s1;
s = (unsigned char *)s2;
i = 0;
while (d[i] && s[i] && i < a)
{
if (d[i] != s[i])
return (d[i] - s[i]);
i++;
}
if (i != a)
{
return (d[i] - s[i]);
}
return (0);
}