Very newb question about std::cin
Posted on 2003-11-19
std::cin >> someStdStringVar;
and then I follow it up with another prompt and
If you've used std::cin frequently you'll know that this won't work. There are still characters left in the buffer (2 in my case) and my bet is that they are the \r\n pair not stored into someStdStringVar previously.
The only way I managed to get them out of there was to add another getline() call before the one I'm interested in.
I tried std::cin.seekg(0,std::ios_base::end); and also std::cin.ignore(INFINITE); before the call to getline() but both caused the following call to getline() to fail to block while waiting for input and filled the buffer with nothing.
I don't mind calling getline() and extra time, but it seems crude. Why is seekg() not working as I expect it to?