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.  
  11. while(input[index++] == ' ');
  12. index--;
  13.  
  14. int end = strlen(input) - 1;
  15. while(input[end] == ' '){
  16. input[end--] = '\0';
  17. }
  18.  
  19. while(input[index] != '\0' && input[index] != '\n' && input[index] != '\r'){
  20. if(input[index] == ' '){
  21. if(space == 0){
  22. space == 1;
  23. printf("%c", input[index]);
  24. }
  25. }
  26. else{
  27. space = 0;
  28. printf("%c", input[index]);
  29. }
  30. index++;
  31. }
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 5312KB
stdin
    Hello   world   from  C    
stdout
Hello   world   from  C