Source of TestStuff20160210.cpp


  1: //TestStuff20160208.cpp

  2: 
  3: #include <iostream>

  4: #include <fstream>

  5: #include <string>

  6: #include <vector>

  7: #include <deque>

  8: #include <algorithm>

  9: #include <iterator>

 10: using namespace std;
 11: 
 12: #include "utilities.h"

 13: using Scobey::Pause;
 14: 
 15: int main(int argc, char* argv[])
 16: {
 17:     //cout << "\nEnter one word per line, or end-of-file to quit:\n";

 18:     //string word;

 19:     //while (getline(cin, word))

 20:     //{

 21:     //    reverse(begin(word), end(word)); //<--Note!

 22:     //    cout << word << endl;

 23:     //}

 24:     //cin.clear();

 25:     //Pause(); //<--Note!

 26: 
 27: 
 28:     //cout << "\nEnter the name of a file containing one word per line: ";

 29:     //string fileName;

 30:     //getline(cin, fileName);

 31:     //ifstream inFile(fileName);

 32:     //cout << "\nHere are the words in that file, with characters reversed:\n";

 33:     //string word;

 34:     //while (getline(inFile, word))

 35:     //{

 36:     //    reverse(begin(word), end(word));

 37:     //    cout << word << endl;

 38:     //}

 39:     //inFile.close();

 40:     //Pause();

 41: 
 42: 
 43:     //cout << "\nEnter the name of a file containing one word per line: ";

 44:     //string fileName;

 45:     //getline(cin, fileName);

 46:     //ifstream inFile(fileName);

 47:     //vector<string> v(5); //<-- Note!

 48:     //copy(istream_iterator<string>(inFile), istream_iterator<string>(), v.begin());

 49:     //cout << "\nHere are the words in that file:\n";

 50:     //copy(v.begin(), v.end(), ostream_iterator<string>(cout, " ! "));

 51:     //inFile.close();

 52:     //Pause(0, "\n");

 53: 
 54: 
 55:     //cout << "\nEnter the name of a file containing one word per line: ";

 56:     //string fileName;

 57:     //getline(cin, fileName);

 58:     //ifstream inFile(fileName);

 59:     //vector<string> v; //<-- Note!                                       vv Note! vv

 60:     //copy(istream_iterator<string>(inFile), istream_iterator<string>(), back_inserter(v));

 61:     //cout << "\nHere are the words in that file:\n";        //vv Note!

 62:     //copy(v.begin(), v.end(), ostream_iterator<string>(cout, "\n"));

 63:     //inFile.close();

 64:     //Pause();

 65: 
 66: 
 67:     cout << "\nEnter the name of a file containing one word per line: ";
 68:     string fileName;
 69:     getline(cin, fileName);
 70:     ifstream inFile(fileName);
 71:     deque<string> d;    //<--Note!                                   // vv Note! vv

 72:     copy(istream_iterator<string>(inFile), istream_iterator<string>(), front_inserter(d));
 73:     cout << "\nHere are the words in that file, in reverse order:\n";
 74:     copy(d.begin(), d.end(), ostream_iterator<string>(cout, "\n"));
 75:     inFile.close();
 76:     Pause();
 77: }