1: //test_io.cpp 2: //Illustrates more integer, character and real input, 3: //including input of whitespace characters. 5: #include <iostream> 6: using namespace std; 8: int main() 9: { 10: cout << "\nThis program is designed to help you experiment with " 11: "C++ input. When entering\ndata, use varying amounts and kinds " 12: "of whitespace to separate values, just to\nsee what happens.\n\n" 13: "Here are the input instructions:\n" 14: "1. Enter three integers, followed by three characters, " 15: "then three real numbers.\n" 16: "2. Now press the Enter key.\n" 17: "3. Next, once again, enter another three integers, followed " 18: "by another three\n characters, and finally another three " 19: "real numbers.\n" 20: "4. Finally, press the Enter key once more.\n\n" 21: "Start entering input on the following line:\n"; 23: int i1, i2, i3, i4, i5, i6; 24: char c1, c2, c3, c4, c5, c6; 25: double r1, r2, r3, r4, r5, r6; 27: cin >> i1 >> i2 >> i3; 28: cin >> c1 >> c2 >> c3; 29: cin >> r1 >> r2 >> r3; 30: cin >> i4 >> i5 >> i6; 31: cin.get(c4); 32: cin.get(c5); 33: cin.get(c6); 34: cin >> r4 >> r5 >> r6; 36: cout << "\nHere are the eighteen values read in, with a " 37: "\"<<\" marker\nat the end of each output line:\n"; 38: cout << "i1: " << i1 39: << "\t\t\ti2: " << i2 40: << "\t\t\ti3: " << i3 << "<<"; 41: cout << "\nc1: " << c1 << "<<" 42: << "\nc2: " << c2 << "<<" 43: << "\nc3: " << c3 << "<<\n"; 44: cout << "r1: " << r1 << "\t\tr2: " 45: << r2 << "\t\tr3: " 46: << r3 << "<<\n"; 47: cout << "i4: " << i4 48: << "\t\t\ti5: " << i5 49: << "\t\t\ti6: " << i6 << "<<"; 50: cout << "\nc4: " << c4 << "<<" 51: << "\nc5: " << c5 << "<<" 52: << "\nc6: " << c6 << "<<\n"; 53: cout << "r4: " << r4 54: << "\t\t\tr5: " << r5 55: << "\t\t\tr6: " << r6 << "<<\n"; 56: cout << endl; 57: }