Skip to content

Instantly share code, notes, and snippets.

@unera
Last active December 14, 2015 14:48
Show Gist options
  • Save unera/5102922 to your computer and use it in GitHub Desktop.
Save unera/5102922 to your computer and use it in GitHub Desktop.
const char *
strstr(const char *str, const char *pat)
{
int i, j;
if (!pat)
return str;
for (i = 0; str[i]; i++) {
for (j = i; ; j++) {
if (pat[j - i] == 0)
return str + i;
if (str[j] != pat[j - i])
break;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment