Skip to content

Instantly share code, notes, and snippets.

@dvtate
Created May 19, 2016 23:08
Show Gist options
  • Save dvtate/d2f138eaaed0944ac9195cdef83cf66f to your computer and use it in GitHub Desktop.
Save dvtate/d2f138eaaed0944ac9195cdef83cf66f to your computer and use it in GitHub Desktop.
char* findOccurance(char* source, char* query){
char* queryCopy = query;
while ( *source != '\0') {
if (*(source++) == *query) {
query++;
while (*query != '\0' && *source == *query) {
source++;
query++;
}
if (*query == '\0')
return source;
query = queryCopy;
}
}
return 0; // return NULL if there were no occurances found...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment