34 lines
1.2 KiB
C
34 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strnstr.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2016/11/03 14:58:36 by jhalford #+# #+# */
|
|
/* Updated: 2016/11/03 16:34:42 by jhalford ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strnstr(const char *big, const char *little, size_t len)
|
|
{
|
|
size_t i;
|
|
int j;
|
|
|
|
i = -1;
|
|
if (!*little)
|
|
return ((char *)big);
|
|
while (big[++i] && i < len)
|
|
{
|
|
j = 0;
|
|
while (big[i + j] == little[j] && i + j < len)
|
|
{
|
|
j++;
|
|
if (!little[j])
|
|
return ((char *)big + i);
|
|
}
|
|
}
|
|
return (NULL);
|
|
}
|