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

  1. //: C20:FileEditor.cpp {O}
  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. #include "FileEditor.h"
  7. #include "../require.h"
  8. #include <fstream>
  9. using namespace std;
  10.  
  11. FileEditor::FileEditor(char* filename) {
  12.   ifstream in(filename);
  13.   assure(in, filename);
  14.   string line;
  15.   while(getline(in, line))
  16.     push_back(line);
  17. }
  18.  
  19. // Could also use copy() here:
  20. void FileEditor::write(ostream& out) {
  21.   for(iterator w = begin();  w != end(); w++)
  22.     out << *w << endl;
  23. } ///:~
  24.