//  File: main2.C
//
//  Sample program using STL vector templates
//  Read the "spell" dictionary and create a sequence
//  of random words

#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <vector>
#include <string>       // STL string template, like BString
#include <algorithm>    // STL algorithms


main() {
   vector<string> V ;
   ifstream ifile("words") ; // "words" is filename of dictionary
   string str ;

  // Get all strings from ifile
  //
   while (1) {
      ifile >> str ;
      if (ifile.eof()) break ;

      V.push_back(str) ;
   }

   random_shuffle(V.begin(), V.end()) ;

   cout << "10 random words" << endl ;
   for (int i = 0 ; i < 10 ; i++) {
      cout << V.back() << endl ;
      V.pop_back() ; // remove last element
   }
}
