/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strnstr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: vvobis +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/03 15:36:41 by vvobis #+# #+# */ /* Updated: 2024/04/10 16:42:02 by vvobis ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strnstr(char const *s1, char const *s2, size_t n) { size_t i; size_t j; if (!*s2) return ((char *)s1); i = 0; while (i < n && s1[i]) { j = 0; if (s1[i + j] == s2[j]) { while (s1[i + j] == s2[j] && s1[i + j] && i + j < n) j++; if (!s2[j]) return ((char *)&s1[i]); } i++; } return (NULL); }