/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strnstr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: dkaiser char *ft_strnstr(const char *haystack, const char *needle, size_t len) { size_t i; size_t k; i = 0; while (i < len) { k = 0; while (haystack[i + k] == needle[k]) { k++; } if (!needle[k]) return ((char *)haystack + i); i++; } return (0); } /* #include */ /* int main() { */ /* char haystack[] = "Hello world"; */ /* char needle[] = "d"; */ /* printf("strnstr: %s\n", strnstr(haystack, needle, 10)); */ /* printf("ft_strnstr: %s\n", ft_strnstr(haystack, needle, 10)); */ /* } */