/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strnstr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/09/28 09:37:24 by erey-bet #+# #+# */ /* Updated: 2022/10/05 16:39:12 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strnstr(const char *big, const char *little, size_t len) { size_t i; size_t y; char *b; b = (char *)big; i = 0; if (!*little || (little == big && ft_strlen(little) <= len)) return (b); while (i < len && big[i]) { y = 0; while (b[i + y] == little[y] && i + y < len) { y++; if (little[y] == '\0') return (&b[i]); } i++; } return (NULL); }