What is the easiest and most efficient way to remove spaces from a string in C?
Easiest and most efficient don't usually go together...
Here's a possible solution:
void remove_spaces(char* s) {
const char* d = s;
do {
while (*d == ' ') {
++d;
}
} while (*s++ = *d++);
}