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

  1. // exios121.cpp
  2. // The tellg 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.        while ( tfile.good() ) {
  12.           streampos here = tfile.tellg();
  13.           tfile.get( ch );
  14.           if ( ch == ' ' )
  15.              cout << "\nPosition " << here << " is a space";
  16.        }
  17.    }
  18.    else {
  19.       cout << "ERROR: Cannot open file 'payroll'." << endl;
  20.    }
  21. }
  22.