home *** CD-ROM | disk | FTP | other *** search
- /*
-
-
- Parsefile() is a modified word count from K&R page 18
-
- M.E.S. 87-01-11
-
- */
- #include "browser.h"
- #include <stdio.h>
- #include <ctype.h>
-
- #define YES 1
- #define NO 0
-
- struct FStatistics *stats;
- FILE *parsefile(fp)
- FILE *fp;
- {
- int c,nl,nw,nc,inword;
-
-
- inword = NO;
- nl = nw = nc = 0;
- while ((c = getc(fp)) != EOF)
- {
- ++nc;
- if ( c == '\n') ++nl;
- if ( c == ' ' || c == '\n' || c == '\t') inword = NO;
- else if (inword == NO)
- {
- inword = YES;
- ++nw;
- }
- }
- stats->bites = nc;
- stats->lines = nl;
- stats->words = nw;
-
- return(fp);
- }
-
-
-