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

  1. // exios115.cpp
  2. #include <iostream.h>
  3. int n[5], i;
  4. void main()
  5. {
  6.     cout << "Enter 5 values, separated by spaces" << endl;
  7.     for( i = 0; i < 5; i++ ) {
  8.         cin >> n[i];
  9.         if( cin.eof() || cin.bad() ) break; // Tests for end-of-file
  10.                                             // or unrecoverable error
  11.         if( cin.fail() ) { // Tests for format conversion error
  12.             cin.clear(); // Clear stream's fail bit
  13.             n[i] = 0;    // and continue processing
  14.         }
  15.     }
  16.     for( i = 0; i < 5; i++ ) { // Prints the values just read
  17.         cout << n[i];
  18.     }
  19. }
  20.