-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strncmp.c
33 lines (30 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: veugenio < [email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/07 21:15:15 by veugenio #+# #+# */
/* Updated: 2021/11/09 19:12:30 by veugenio ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *str1, const char *str2, size_t size)
{
size_t i;
i = 0;
if (str1 == str2 || size == 0)
{
return (0);
}
while (i < size)
{
if (str1[i] != str2[i] || str1[i] == '\0' || str2[i] == '\0')
{
return (((unsigned char *)str1)[i] - ((unsigned char *)str2)[i]);
}
i++;
}
return (0);
}