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

  1. //: C20:Stack3.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. // Using a vector as a stack; modified Stack1.cpp
  7. #include "../require.h"
  8. #include <iostream>
  9. #include <fstream>
  10. #include <vector>
  11. #include <string>
  12. using namespace std;
  13.  
  14. int main(int argc, char* argv[]) {
  15.   requireArgs(argc, 1);
  16.   ifstream in(argv[1]);
  17.   assure(in, argv[1]);
  18.   vector<string> textlines;
  19.   string line;
  20.   while(getline(in, line)) 
  21.     textlines.push_back(line + "\n");
  22.   while(!textlines.empty()) {
  23.     cout << textlines.back();
  24.     textlines.pop_back();
  25.   }
  26. } ///:~
  27.