libft/ft_strncmp.c
2020-12-11 17:19:05 +01:00

29 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/29 00:13:31 by apommier #+# #+# */
/* Updated: 2020/11/29 17:14:21 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
int i;
i = 0;
while (n && s1[i] && s2[i])
{
if (s1[i] != s2[i])
return ((unsigned char)(s1[i] - s2[i]));
n--;
i++;
}
return (0);
}