In C++, what happens to excess input, if it is given? Does it get stored somewhere or is completely ignored?
For example, this sample code:
#include <iostream>
using namespace std;
int main()
{
char a, b, c;
cout << "Enter three letters: ";
cin.get(a).get(b).get(c);
cout << "a: " << a << "\nb: " << b << "\nc: " << c << endl;
return 0;
}
Which just asks for three letters, will let me type in as many as I want. Where do all the rest go? Preferably nowhere… right?
They go into an input buffer. When your process exits (without reading them) the buffer is discarded (and the unread contents along with it).