25 lines
1.1 KiB
C
25 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strncmp.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/10/10 12:21:33 by mcolonna #+# #+# */
|
|
/* Updated: 2023/10/10 14:39:03 by mcolonna ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
int ft_strncmp(const char *s1, const char *s2, size_t n)
|
|
{
|
|
unsigned int i;
|
|
|
|
if (n == 0)
|
|
return (0);
|
|
i = 0;
|
|
while (i < n - 1 && s1[i] && s1[i] == s2[i])
|
|
i++;
|
|
return ((unsigned char)s1[i] - (unsigned char)s2[i]);
|
|
}
|