Reputation: 861
What happens with the redundant input we give to a program? Suppose you want to read an integer in variable a
from the standard input, but you enter five space separated integers. The terminal gives the first line of input to the program. a
is filled with the first integer. Now, what happens to the other input you supplied? Can you get acces to it? Thanks in advance.
Upvotes: 0
Views: 61
Reputation: 1073
You can read multiple inputs:
int a, b;
cin >> a >> b;
int c;
cin >> c;
Or, you can simply ignore any extra input, and it will be discarded when the program exits.
Upvotes: 2
Reputation: 463
I think the other 4 integers are left in the stream. So if you have more cins later you can get them
Upvotes: 2