home *** CD-ROM | disk | FTP | other *** search
- // 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);
- }
-