1-12.c

演習 1-12 入力した単語を1行に一つずつ印字するプログラムを書け。

#include <stdio.h>

#define IN      1
#define OUT     0

main()
{
        int c, state;

        state = OUT;
        while ((c = getchar()) != EOF) {
                if (c == ' ' || c == '\n' || c == '\t') {
                        if (state == IN)
                                putchar('\n');
                        state = OUT;
                } else {
                        putchar(c);
                        state = IN;
                }
        }
}


$ ./a.out < 1-12.c
#include

#define
IN
1
#define
OUT
0
main()
{
int
c,
state;
state
=
OUT;
...