Skip to content

Instantly share code, notes, and snippets.

@Yangff
Last active June 21, 2017 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yangff/d29868dd3b9dd7962de52b039b3b041f to your computer and use it in GitHub Desktop.
Save Yangff/d29868dd3b9dd7962de52b039b3b041f to your computer and use it in GitHub Desktop.
void del_substr(char *str, const char *substr) {
for (char *c1, *c2; *str; str+=!!(*c2)) {
for (c1 = str, c2 = (char*)substr; *c1 == *c2 && *c1 && *c2; c1++, c2++);
if (*c2 == 0) {
for (c2 = str; *c2 = *c1; c2++, c1++);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment