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