/ Published in: C
Expand |
Embed | Plain Text
int del_substr(char* str, const char* substr) { while (*str++ != '\0') { char* s = str; const char* c = substr; while (*s == *c) { s++; c++; if (*c == '\0') { do { *str++ = *s++; } while (*s != '\0'); return 1; } } } return 0; } int main (int argc, char const *argv[]) { char s[] = "ABCDEFGHIJKLMN"; char substr[] = "EFG"; int i = del_substr(s, substr); return 0; }
You need to login to post a comment.
