Archived
1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
libft/ft_strncmp.c
2023-11-06 17:25:35 +01:00

26 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/05 10:40:45 by adjoly #+# #+# */
/* Updated: 2023/11/06 14:53:38 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
size_t i;
i = 0;
if (n == 0)
return (0);
while (s1[i] == s2[i] && s1[i] && i < n - 1)
i++;
return ((unsigned char)s1[i] - (unsigned char)s2[i]);
}