fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(void) {
  5. char input[10000];
  6. char output[10000];
  7. fgets(input, 1000, stdin);
  8. int index = 0;
  9. int space = 0;
  10. while(input[index++] == ' ');
  11. int end = strlen(input) - 1;
  12. while(input[end] == ' '){
  13. input[end--] = '\0';
  14. }
  15.  
  16. while(input[index] != '\0' && input[index] != '\n' && input[index] != '\r'){
  17. if(input[index] == ' '){
  18. if(space == 0){
  19. space == 1;
  20. printf("%c", input[index]);
  21. }
  22. }
  23. else{
  24. space = 0;
  25. printf("%c", input[index]);
  26. }
  27. index++;
  28. }
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.01s 5324KB
stdin
    Hello   world   from  C    
stdout
ello   world   from  C