home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
CPROG
/
BEGINCPP.ZIP
/
#10.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1990-08-05
|
433b
|
26 lines
// STR_CNT.CXX : a word count program that uses stream i/o
#include <stream.hxx>
#include <ctype.h>
main()
{
int word_cnt = -1;
void found_next_word (void);
while ( cin.good() ) { // ^Z ends input
word_cnt++; // increment counts
found_next_word ();
}
cout << "word count is " << word_cnt << "\n";
}
void found_next_word (void)
{
char c;
cin >> c;
while (!isspace (c))
cin.get (c);
}