home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK4 / SAMPLES / IOSTUTOR / EXIOS120.CP$ / EXIOS120
Encoding:
Text File  |  1991-11-25  |  505 b   |  22 lines

  1. // exios120.cpp
  2. // The seekg member function
  3. #include <fstream.h>
  4.  
  5. void main()
  6. {
  7.    char ch;
  8.  
  9.    ifstream tfile( "payroll", ios::binary | ios::nocreate );
  10.    if( tfile ) {
  11.       tfile.seekg( 8 );      // Seek eight bytes in (past salary)
  12.       while ( tfile.good() ) { // EOF or failure stops the reading
  13.          tfile.get( ch );
  14.          if( !ch ) break; // quit on null
  15.          cout << ch;
  16.       }
  17.    }
  18.    else {
  19.       cout << "ERROR: Cannot open file 'payroll'." << endl;
  20.    }
  21. }
  22.