-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strncmp.c
29 lines (26 loc) · 1.17 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lubaujar <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/11 11:48:03 by lubaujar #+# #+# */
/* Updated: 2014/11/13 19:49:30 by lubaujar ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(char const *s1, char const *s2, size_t n)
{
unsigned int len_s1;
unsigned int len_s2;
len_s1 = ft_strlen(s1);
len_s2 = ft_strlen(s2);
if (n == 0)
return (0);
if (len_s1 > n)
n = len_s1 + 1;
if (len_s2 > n)
n = len_s2 + 1;
return (ft_memcmp(s1, s2, n));
}