home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************
- Copyright (c) 1984 All Rights Reserved Karl L. Remmler
- Not for commercial use or profit
-
- WC.c - word count and redirected IO (CI-C86)
-
- NOTE #1: See K&R, Chapters 1 and 7.2, pages 18 and 144, respectively.
-
- NOTE #2: USAGE: ex28 <filename
-
- **************************************************************************/
-
- #define HEATH /* . . . . . . . . . . delete this line for IBM-PC */
-
- #define puts printf /* . . . . . . . . . . . . . .conversion from BDS-C */
- #include "stdio.h"
-
- #ifdef HEATH
- #include "heath.h"
- #linclude "locate.c"
- #else
- #include "ibm.h"
- #endif
-
- main()
- {
- int c, nl, nw, nc, inword;
-
- inword = NO;
- nl = nw = nc = 0;
- while ((c = getchar()) != EOF) {
- ++nc;
- if (c == '\n')
- ++nl;
- if (c == ' ' || c == '\n' || c == '\t')
- inword = NO;
- else if (inword == NO) {
- inword = YES;
- ++nw;
- }
- }
- CLS;
- locate(10, 30);
- printf("%d lines", nl);
- locate(12, 30);
- printf("%d words", nw);
- locate(14, 30);
- printf("%d characters", nc);
- CUH;
- exit();
- }