1  #ifndef HEAD_H
 2  #define HEAD_H
 3
 4  #include <iostream>
 5  #include <fstream>
 6  #include <string>
 7
 8  #endif
 9
10  /*****************************************************
11  * Program file3.C from page 22 of Lippman            *
12  * Modified to include namespace, preprossor commands *
13  * and endl macro as called for                       *
14  *  Ruben Safir June 29th, 2008                       * 
15  *****************************************************/
16  using namespace std;
17
18  int main(){
19
20          ofstream OUTFILE("/home/ruben/cplus/testpass.txt");
21          ifstream INFILE("/etc/passwd");
22          if(! INFILE ){
23                  cerr << "Can't open password file";
24                  return -1;
25          }
26          if(! OUTFILE ){
27                  cerr << "Can't open testpass.txt file";
28                  return -2;
29          }
30
31          string word;
32          while( INFILE >> word)
33                  OUTFILE << word << ' ';
34
35          return 0;
36  }
37