2019/08/06-2
//字符的删除 #include <iostream> #include <string> using namespace std; char* deleteChar(char* src, const char c) { char* newstr = src; char* oldstr = src; while (*oldstr != '\0') { if (*oldstr != c) { *newstr = *oldstr; newstr++; } oldstr++; } *newstr = '\0'; return src; } int main() { char str[] = "acdcercfgcss"; cout<<deleteChar(str, 'c'); system("pause"); return 0; }
#C/C++#