42_cub3d/Libft/ft_strncmp.c
2024-10-09 03:35:09 +02:00

26 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: grobledo <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/04 14:33:04 by grobledo #+# #+# */
/* Updated: 2023/02/04 14:33:06 by grobledo ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *s1, const char *s2, size_t size)
{
size_t i;
i = 0;
while ((s1[i] || s2[i]) && (i < size))
{
if (s1[i] != s2[i])
return (((unsigned char)(s1[i]) - ((unsigned char)s2[i])));
i++;
}
return (0);
}