home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
words.zip
/
wcount.c
next >
Wrap
C/C++ Source or Header
|
1994-06-24
|
524b
|
32 lines
/* WCOUNT.C */
/* (c) 1994, Matt McLeod */
/* See WORDS.C for license info */
/* This is the "word-counting" engine for WORDS. */
#include <stdio.h>
#include <ctype.h>
#define BOOL int
#define TRUE 1
#define FALSE 0
int count_words (FILE *thefile)
{
BOOL last_space = FALSE;
int words = 0;
char charin;
while (!feof(thefile))
{
charin = fgetc(thefile);
if (isspace(charin) && !last_space)
{
words++;
last_space = TRUE;
} else last_space = FALSE;
}
return words;
};