|
|
1.1 root 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: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.