Here are a few questions to help you clarify your understanding of input.
For each of the code fragments below, show what happens when the user types this sequence of characters:
9+4uaq^-5*-7
That is, for each code fragment:
You should assume that each fragment is independent of the others (i.e. so each input begins at the '9' in the stream of input).
The type of the variables used is indicated by their first letter (c is char, s is short, etc.).
cin >> c1 >> c2 >> c3;
c1: '9' c2: '+' c3: '4' left: uaq^-5*-7 errors: none
cin >> s1 >> c1 >> s2;
s1: 9 c1: '+' s2: 4 left: uaq^-5*-7 errors: none
cin >> s1 >> s2 >> s3;
s1: 9 s2: 4 s3: n/a left: uaq^-5*-7 error: fail
cin >> s1 >> s2 >> c1;
s1: 9 s2: 4 c1: 'u' left: aq^-5*-7 errors: none
cin >> d1 >> d2 >> c1;
d1: 9.0 d2: 4.0 c1: 'u' left: aq^-5*-7 errors: none
cin >> s1 >> c1 >> s2 >> c2 >> c2 >> c2 >> c3 >> d3 >> c4 >> d4;
s1: 9 c1: '+' s2: 4 c2: 'u' c2: 'a' c2: 'q' c3: '^' d3: -5.0 c4: '*' d4: -7.0 left: nothing errors: none