Remove spaces from a string in C
c, spaces, string
Solution
Easiest and most efficient don't usually go together…
Here's a possible solution for in-place removal:
void remove_spaces(char* s) {
char* d = s;
do {
while (*d == ' ') {
++d;
}
} while (*s++ = *d++);
}
Problem
What is the easiest and most efficient way to remove spaces from a string in C?