-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_strncmp.c
38 lines (33 loc) · 1.28 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
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jony <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/21 20:03:35 by mhasan #+# #+# */
/* Updated: 2019/11/04 22:03:33 by jony ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
int a;
a = 0;
if (n == 0)
return (0);
while (s1[a] == s2[a] && s1[a] != '\0' && s2[a] != '\0' && a < n - 1)
a++;
return ((unsigned char)s1[a] - (unsigned char)s2[a]);
}
int main(void)
{
char *s1;
char *s2;
int ret;
s1 = "zyxbcdefgh";
s2 = "abcdwxyz";
printf("%d", ft_strncmp(s1, s2, 0));
//printf("%d", ret);
return (0);
}