30 lines
1.2 KiB
C
30 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strnstr.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: pbonilla <eirodeis.lepnj@gmail.com> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2020/11/09 19:15:12 by pbonilla #+# #+# */
|
|
/* Updated: 2021/01/30 18:31:22 by pbonilla ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strnstr(const char *big, const char *little, size_t len)
|
|
{
|
|
size_t len_l;
|
|
|
|
if (*little == 0)
|
|
return ((char *)big);
|
|
len_l = ft_strlen(little);
|
|
while (*big != 0 && len-- >= len_l)
|
|
{
|
|
if (*big == *little && ft_strncmp(big, little, len_l) == 0)
|
|
return ((char *)big);
|
|
big++;
|
|
}
|
|
return (NULL);
|
|
}
|