libft/str/ft_strnstr.c
Raphael 2cf0714dc7
docs(str): moving the actual documentation on the header
- The documentation on the header allow u to see on the files where the
header is inclued
2025-09-05 16:30:00 +02:00

37 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:57:44 by rparodi #+# #+# */
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.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);
}