TheQuack45

K&R C Language -- Exercise 1-9

May 31st, 2016
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.24 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. /* Copy input to output, converting multiple blanks to one blank */
  4. main()
  5. {
  6.     int c;
  7.    
  8.     while ((c = getchar()) != EOF) {
  9.         if (c == ' ') {
  10.             putchar(c);
  11.             while ((c = getchar()) == ' ') { }
  12.         }
  13.         putchar(c);
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment