37 lines
1.3 KiB
C
37 lines
1.3 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* 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);
|
|
}
|