style: reoarginsed the file and fix the makefile

This commit is contained in:
Raphael 2024-10-31 12:41:17 +01:00
parent ecd9608320
commit a5fe7484a1
46 changed files with 140 additions and 49 deletions

37
str/ft_strnstr.c Normal file
View file

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:57:44 by rparodi #+# #+# */
/* Updated: 2023/11/13 19:17:49 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnstr(const char *big, const char *little, size_t len)
{
size_t i;
size_t j;
i = 0;
if (len == 0 && (!big || !little))
return (NULL);
if (!little[i])
return ((char *)big);
while (big[i] && i < len)
{
j = 0;
while (i + j < len && little[j] == big[i + j])
{
j++;
if (little[j] == '\0')
return ((char *)(big + i));
}
i++;
}
return (0);
}