From 5b653ccffdc33c8774697a93cad0b499b88dca71 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 28 Jul 2019 21:12:28 +0200 Subject: std library function almost done, tested with libft-unit-tests --- ft_strstr.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ft_strstr.c (limited to 'ft_strstr.c') diff --git a/ft_strstr.c b/ft_strstr.c new file mode 100644 index 0000000..0209de4 --- /dev/null +++ b/ft_strstr.c @@ -0,0 +1,27 @@ +#include +#include +#include "libft.h" + +char *ft_strstr(const char *haystack, const char *needle) +{ + size_t i; + char *cursor; + + cursor = (char*)haystack; + if (!ft_strlen(needle)) + return (cursor); + while (*cursor) + { + i = 0; + while (needle[i] && cursor[i]) + { + if (needle[i] != cursor[i]) + break ; + i++; + } + if (i == ft_strlen(needle)) + return (cursor); + cursor++; + } + return (NULL); +} -- cgit