/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strnstr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mdenys +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/11/01 18:43:20 by mdenys #+# #+# */ /* Updated: 2020/11/04 18:41:20 by mdenys ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strnstr(const char *hst, const char *ndl, size_t size) { unsigned int i; unsigned int j; if (ndl[0] == '\0') return ((char *)hst); i = 0; while (hst[i]) { j = 0; if (hst[i] == ndl[j]) { while (hst[i + j] == ndl[j] && i + j < size) { j++; if (!ndl[j]) return ((void *)(hst + i)); } } i++; } return (0); }