etc/services - sync with NetBSD-8
[minix.git] / external / bsd / flex / dist / examples / fastwc / mywc.c
blob92e5a366c12884cf71c8f5a50966adec34b04fdc
1 /* A simple but fairly efficient C version of the Unix "wc" tool */
3 #include <stdio.h>
4 #include <ctype.h>
6 main()
8 register int c, cc = 0, wc = 0, lc = 0;
9 FILE *f = stdin;
11 while ((c = getc(f)) != EOF) {
12 ++cc;
13 if (isgraph(c)) {
14 ++wc;
15 do {
16 c = getc(f);
17 if (c == EOF)
18 goto done;
19 ++cc;
20 } while (isgraph(c));
22 if (c == '\n')
23 ++lc;
25 done: printf( "%8d%8d%8d\n", lc, wc, cc );