void removeBlanks(char * string) {
int len = (int) strlen(string), count = 0;
for (int i = 0; i < len; i++) {
if (string[i] == ' ') {
count++;
continue;
}
string[i - count] = string[i];
}
string[len-count]=0;
}
用了几种复杂的方法,最后才回归本质😅。