fork(1) download
  1. #include <stdio.h>
  2.  
  3. void rSpace(char *string) {
  4. int j = 0;
  5. char last = '\0';
  6. for (int i = 0; string[i] != '\0'; i++) {
  7. if (string[i] != ' ' || last != ' ') {
  8. string[j] = string[i];
  9. j++;
  10. last = string[i];
  11. }
  12. }
  13. string[j] = '\0';
  14. }
  15.  
  16. int main() {
  17. char frase2[200] = "minha frase com algums espaços";
  18. rSpace(frase2);
  19. printf("%s\n", frase2);
  20. }
  21.  
  22. //http://pt.stackoverflow.com/q/183633/101
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
minha frase com algums espaços