Skip to content

Instantly share code, notes, and snippets.

@erik
Created August 23, 2011 02:33
Show Gist options
  • Save erik/1164194 to your computer and use it in GitHub Desktop.
Save erik/1164194 to your computer and use it in GitHub Desktop.
int count = 0, str_len = strlen(str), sub_len = strlen(substr), i, j;
for(i = 0; i < str_len - sub_len; ++i) {
j = 0;
while(str[i++] == substr[j++]) {}
if(j == sub_len) count++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment