add: strstr
This commit is contained in:
parent
37c15e5740
commit
c9c5479bbb
14
src/string/strstr.c
Normal file
14
src/string/strstr.c
Normal file
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user