From dc252d40ff016b590753c683ca0fd4ef0e08ae02 Mon Sep 17 00:00:00 2001 From: celso Date: Sat, 5 Nov 2022 17:53:10 -0300 Subject: [PATCH] twelfth exercise --- 1-12.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 1-12.c diff --git a/1-12.c b/1-12.c new file mode 100644 index 0000000..b7083f8 --- /dev/null +++ b/1-12.c @@ -0,0 +1,20 @@ +#include + +#define IN 1 /* inside a word */ +#define OUT 0 /* outside a word */ + +int main(){ + int c, state; + state = OUT; + while ((c = getchar()) != EOF) { + if (c == ' ' || c == '\n' || c == '\t'){ + state = OUT; + putchar('\n'); + } + else if (state == OUT) { + state = IN; + putchar(c); + } + } + return 0; +}