home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C20 / TokenizeTest.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  724 b   |  28 lines

  1. //: C20:TokenizeTest.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. //{L} StreamTokenizer
  7. // Test StreamTokenizer
  8. #include "StreamTokenizer.h"
  9. #include "../require.h"
  10. #include <iostream>
  11. #include <fstream>
  12. #include <set>
  13. using namespace std;
  14.  
  15. int main(int argc, char* argv[]) {
  16.   requireArgs(argc, 1);
  17.   ifstream in(argv[1]);
  18.   assure(in, argv[1]);
  19.   StreamTokenizer words(in);
  20.   set<string> wordlist;
  21.   string word;
  22.   while((word = words.next()).size() != 0)
  23.     wordlist.insert(word);
  24.   // Output results:
  25.   copy(wordlist.begin(), wordlist.end(),
  26.     ostream_iterator<string>(cout, "\n"));
  27. } ///:~
  28.