samir82show

c_ch01_ex12.c

Sep 22nd, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. /*Exercise 1-12. Write a program that prints its input one word per line.*/
  2. #include <stdio.h>
  3. int main()
  4. {
  5. int flag = 1, c;
  6. while ((c = getchar()) != EOF) {
  7. if (c == ' ' || c == '\t' || c == '\n') {
  8. if (flag == 0) {
  9. putchar('\n');
  10. flag = 1;
  11. }
  12. } else {
  13. putchar(c);
  14. flag = 0;
  15. }
  16. }
  17. return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment