Files
SortStack/lib/libft/ft_strncmp.c
T
HexPloR 4c83562ca9 ez
2024-06-24 00:05:59 +02:00

29 lines
1.2 KiB
C
Executable File

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yantoine <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/11 08:46:16 by yantoine #+# #+# */
/* Updated: 2023/11/30 09:28:36 by yantoine ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
size_t index;
index = 0;
while (*(unsigned char *)(s1 + index) && \
*(unsigned char *)(s2 + index) && index < n)
{
if (*(s1 + index) != *(s2 + index))
return (*(s1 + index) - *(s2 + index));
index++;
}
return (0);
}