-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strncmp.c
28 lines (25 loc) · 1.13 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: muraler <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/10 17:04:50 by muraler #+# #+# */
/* Updated: 2022/02/10 17:05:12 by muraler ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *str1, const char *str2, size_t n)
{
size_t i;
i = 1;
if (!n)
return (0);
while (*str1 == *str2 && i++ < n && *str1 && *str2)
{
str1++;
str2++;
}
return ((unsigned char)*str1 - (unsigned char)*str2);
}