diff options
Diffstat (limited to 'ch1/one_word.c')
-rw-r--r-- | ch1/one_word.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ch1/one_word.c b/ch1/one_word.c new file mode 100644 index 0000000..8d50542 --- /dev/null +++ b/ch1/one_word.c @@ -0,0 +1,16 @@ +#include<stdio.h> + +/* + * Print input one word per line. + */ +main() { + int c; + + while ((c = getchar()) != EOF) { + if (c == ' ' || c == '\n' || c == '\t') + putchar('\n'); + else { + putchar(c); + } + } +} |