core: opti: strstr
This commit is contained in:
parent
48b500c443
commit
77bbc2d383
@ -1,14 +1,14 @@
|
|||||||
char *strstr(const char *haystack, const char *needle)
|
char *strstr(const char *haystack, const char *needle)
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
const char *start = haystack;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = strlen(needle);
|
len = strlen(needle);
|
||||||
while (haystack[i] != '\0')
|
while (*start != '\0')
|
||||||
{
|
{
|
||||||
if (strncmp(haystack + i, needle, len) == 0)
|
if (strncmp(start, needle, len) == 0)
|
||||||
return haystack + i;
|
return start;
|
||||||
i++;
|
start++;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user