Adding the libft

This commit is contained in:
Raphael 2024-10-31 17:24:36 +01:00
parent 1b98b537b7
commit c947e43e51
62 changed files with 2098 additions and 19 deletions

31
libft/str/ft_strncmp.c Normal file
View file

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:56:56 by rparodi #+# #+# */
/* Updated: 2023/11/09 13:16:39 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
size_t i;
int diff;
i = 0;
while ((s1[i] || s2[i]) && i < n)
{
if (s1[i] != s2[i])
{
diff = (unsigned char)s1[i] - (unsigned char)s2[i];
return (diff);
}
i++;
}
return (0);
}