34 lines
1.2 KiB
C
34 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: o_ :::::: ::: */
|
|
/* ft_strnstr.c :+: / :+::+: :+: */
|
|
/* +:+ > +:++:+ +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#++#++:++#++ */
|
|
/* +#+ +#+#+ +#++#+ +#+ \o/ */
|
|
/* Created: 2024/10/10 17:00:31 by whaffman #+#+# #+#+# #+# #+# | */
|
|
/* Updated: 2024/10/10 17:00:31 by whaffman ### ### ### ### / \ */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#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')
|
|
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);
|
|
}
|