fork(6) download
  1. #include <stdio.h>
  2.  
  3. void removerSpacos(char str[]) {
  4. int j = 1;
  5. for (int i = 1; str[i]; i++) {
  6. if (str[i] != ' ' || (str[i - 1] != ' ')) {
  7. str[j] = str[i];
  8. j++;
  9. }
  10. }
  11. str[j] = '\0';
  12. }
  13. int main() {
  14. char frase[] = "Ola Mundo!";
  15. removerSpacos(frase);
  16. printf("%s", frase);
  17. return 0;
  18. }
  19.  
  20. //http://pt.stackoverflow.com/q/120141/101
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
Ola Mundo!