Sunday, November 28, 2010

Write a program that prints its input one word per line.

#include
#define IN 1 /* inside a word */
#define OUT 0 /* outside a word */
/* count lines, words, and characters in input */
int main()
{
int c;
int inspace = 0;


while((c = getchar()) != EOF)
{
if(c == ' ' || c == '\t' || c == '\n')
{
if(inspace == 0)
{
inspace = 1;
putchar('\n');

}// End Of Second IF
}// End Of First IF
else
{
putchar(c);
inspace = 0;
}

}// End of WHILE
return 0;
}