Created
July 17, 2015 14:09
-
-
Save Riketta/a66e735cba8f73f4cbf4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int my_strstr(char *haystack, char *needle) | |
{ | |
int offset = -1; | |
//for (s = str; *s; ++s); | |
char *_haystack; | |
char *_needle = needle; // wtf | |
for (_haystack = haystack; *_haystack; ++_haystack) | |
{ | |
if (*_haystack == *_needle) | |
offset = *_haystack; | |
if (offset != -1 && *_needle) | |
{ | |
if (*_haystack != *_needle) | |
{ | |
*_haystack = offset + 1; // rly? | |
*_needle = needle; | |
offset = -1; | |
} | |
++_needle; | |
} | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment