#include <stdio.h>
void rSpace(char *string) {
int j = 0;
char last = '\0';
for (int i = 0; string[i] != '\0'; i++) {
if (string[i] != ' ' || last != ' ') {
string[j] = string[i];
j++;
last = string[i];
}
}
string[j] = '\0';
}
int main() {
char frase2[200] = "minha frase com algums espaços";
rSpace(frase2);
}
//http://pt.stackoverflow.com/q/183633/101
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIHJTcGFjZShjaGFyICpzdHJpbmcpIHsKCWludCBqID0gMDsKCWNoYXIgbGFzdCA9ICdcMCc7CiAgICBmb3IgKGludCBpID0gMDsgc3RyaW5nW2ldICE9ICdcMCc7IGkrKykgewogICAgICAgIGlmIChzdHJpbmdbaV0gIT0gJyAnIHx8IGxhc3QgIT0gJyAnKSB7CiAgICAgICAgICAgIHN0cmluZ1tqXSA9IHN0cmluZ1tpXTsKICAgICAgICAgICAgaisrOwogICAgICAgCSAgICBsYXN0ID0gc3RyaW5nW2ldOwogICAgICAgIH0KICAgIH0KICAgc3RyaW5nW2pdID0gJ1wwJzsKfQoKaW50IG1haW4oKSB7CiAgICBjaGFyIGZyYXNlMlsyMDBdID0gIm1pbmhhICAgZnJhc2UgY29tICAgYWxndW1zICAgICBlc3Bhw6dvcyI7CiAgICByU3BhY2UoZnJhc2UyKTsKICAgIHByaW50ZigiJXNcbiIsIGZyYXNlMik7Cn0KCi8vaHR0cDovL3B0LnN0YWNrb3ZlcmZsb3cuY29tL3EvMTgzNjMzLzEwMQ==