From 39c0cbcc70aff47e17107826aa76cb525c83b122 Mon Sep 17 00:00:00 2001 From: Adam Carpenter Date: Tue, 9 Jul 2019 16:00:48 -0400 Subject: ch2 --- wc.c | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 wc.c (limited to 'wc.c') diff --git a/wc.c b/wc.c deleted file mode 100644 index 4a5007d..0000000 --- a/wc.c +++ /dev/null @@ -1,29 +0,0 @@ -#include - -#define IN 1 // inside a word -#define OUT 0 // outside a word - -/* - * Count lines, words, and characters in input. - */ -main() { - int c, nl, nw, nc, state; - - state = OUT; - nl = nw = nc = 0; - - while ((c = getchar()) != EOF) { - ++nc; - - if (c == '\n') - ++nl; - if (c == ' ' || c == '\n' || c == '\t') - state = OUT; - else if (state == OUT) { - state = IN; - ++nw; - } - } - - printf("%d %d %d\n", nl, nw, nc); -} -- cgit v1.2.3