This is an interview question Looking for best optimal solution to trim multiple spaces from a string. This operation should be in-place operation.
input =
I'd just go with this:
int main(int argc, char* argv[]) { char *f, *b, arr[] = " This is a test. "; f = b = arr; if (f) do { while(*f == ' ' && *(f+1) == ' ') f++; } while (*b++ = *f++); printf("%s", arr); return 0; }