34 lines
1.2 KiB
C
34 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strnstr.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/07/05 18:42:11 by whaffman #+# #+# */
|
|
/* Updated: 2024/07/10 12:01:36 by whaffman ### ########.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 (*little == '\0' || len == 0)
|
|
return ((char *) big);
|
|
while (big[i] && i < len)
|
|
{
|
|
j = 0;
|
|
while (little[j] && big[i + j] == little [j] && i + j < len)
|
|
j++;
|
|
if (little[j] == '\0')
|
|
return ((char *) &big[i]);
|
|
i++;
|
|
}
|
|
return (NULL);
|
|
}
|