Skip to content
Snippets Groups Projects
Commit c10d6541 authored by Avi Kivity's avatar Avi Kivity
Browse files

string: implement strstr()

parent c76cbda1
No related branches found
No related tags found
No related merge requests found
#include <string.h>
#include <algorithm>
const char* strrchr(const char* s, int c)
{
......@@ -28,3 +29,14 @@ char* stpcpy(char* p, const char* s)
*p = '\0';
return p;
}
const char* strstr(const char* haystack, const char* needle)
{
auto e1 = haystack + strlen(haystack);
auto e2 = needle + strlen(needle);
auto p = std::search(haystack, e1, needle, e2);
if (p == e1) {
return nullptr;
}
return p;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment