Today's goal is to create a program that removes all the whitespace from a string. The trick is you must do it in place (without creating another copy of the string). If you want to use a language where strings are immutable just simple overwrite the string when needed.
Comments:
Anonymous - 10 years ago
void removeWhiteSpace(char *cPtr) { while (*cPtr) { if (*cPtr == ' ') { strcpy(cPtr, cPtr+1); } cPtr++; } }
reply permalink