/* Exercise 1-12 of _The C Programming Language. "Write a program that prints its input one word per line." 11/12/01 */ /* This program needs to: */ /* -recognize separate words in the input */ /* -copy the characters in those words to the output */ /* -put each word on a new line */ #include #define IN 1 /* inside a word */ #define OUT 0 /* outside a word */ main () { int c, state; c = getchar(); while(c != EOF) { if (c == ' ' || c == '\n' || c == '\t') { state = OUT; printf("\n"); } else { state = IN; putchar(c); } c = getchar(); } } /* This seems to work, except for when I use two spaces between words instead of one. I know that this is because every time the program comes to a space, it does "\n" but I don't know how to write it better. Also, how do I get this program to end? */