home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 099 / IOSTREAM.ZIP / EX_F02.CPP < prev    next >
C/C++ Source or Header  |  1993-01-07  |  575b  |  33 lines

  1. // EXAMPLE FILEIO-02
  2.  
  3. // GIVE THE USER A CHANCE TO APPEND
  4. // RECORDS TO THE FILE
  5.  
  6. #include <header.h>
  7.  
  8. const int max = 100 ;
  9.  
  10. ////////////////////////////////////
  11.  
  12. int main()
  13. {
  14.    char buffer[max] ;
  15.    ofstream file_out("OUTPUT.DAT" , ios::out | ios::app) ;
  16.    if (!file_out)
  17.    {
  18.       cout << "OPEN FAILED\n" ;
  19.       PAUSE() ;
  20.       exit(1) ;
  21.    }
  22.  
  23.    cout << "Enter a line of data: " ;
  24.    while (!cin.get(buffer , max).eof\())
  25.    {
  26.       file_out << buffer << endl ;
  27.       cout << "Next line: " ;
  28.       cin >> FLUSH ;
  29.    }
  30.  
  31.    return 0 ;
  32. }
  33.