fork(1) download
  1. #include <stdio.h>
  2. #include <stdbool.h> /* C99, but a good idea to use nonetheless */
  3.  
  4. int main() {
  5. bool was_space; /* state variable */
  6. char c; /* one-character buffer */
  7.  
  8. while ( ( c = getchar() ) != EOF ) {
  9. if ( ! was_space || c != ' ' ) putchar( c );
  10. was_space = c == ' ';
  11. }
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0.01s 1724KB
stdin
one   two    four     
stdout
one two four