From c9c5479bbb35b3a6b133e8ff68f59975668784a5 Mon Sep 17 00:00:00 2001 From: starnakin Date: Fri, 6 Sep 2024 23:09:04 +0200 Subject: [PATCH] add: strstr --- src/string/strstr.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/string/strstr.c diff --git a/src/string/strstr.c b/src/string/strstr.c new file mode 100644 index 0000000..4586058 --- /dev/null +++ b/src/string/strstr.c @@ -0,0 +1,14 @@ +char *strstr(const char *haystack, const char *needle) +{ + size_t i = 0; + size_t len; + + len = strlen(needle); + while (haystack[i] != '\0') + { + if (strncmp(haystack + i, needle, len) == 0) + return haystack + i; + i++; + } + return NULL; +}