Electrical and Computer Engineering
9 of 29
UAH
CPE 112
Input Failure (How
Things Can Go Very Wrong)
•If an input operation fails because of invalid data, the cin stream enters the silent but deadly fail state. (No error)
•Example:
–int i = 10, j = 20, k = 30;
–cin >> i >> j >> k;
–cout << i: ” << i << “  j: ” << j
–     << “  k: ” << k;
–Input Data 1234.56 7 89 produces this output:
–i: 1234  j: 20  k: 30
–