In my book, C++ Primer Plus 4th Edition, it says that cin.get(buf, 80) will set the failbit and block further reading if it encounters an emtpy line (just a newline in the stream).
So in order to use cin again, you should use cin.clear(). Why doesn't this simple code work then (it should wait for the user to enter something at the end):
Code:
#include <iostream>
using namespace std;
int main()
{
int i;
char buf[80];
cout << "Enter an integer: ";
cin >> i;
cout << "You entered: " << i << endl;
cin.get(buf, 80); // Just an example, I know you can use cin.get() here.
cin.clear();
cin.get();
return 0;
}
It works if I add cin.ignore(), but there shouldn't be anything left in the stream since I read the trailing newline with cin.get(buf, 80)?