View Single Post
Old Apr 20th, 2007, 9:33 PM   #23
Twilight
Programmer
 
Join Date: Apr 2006
Location: Calgary, Alberta
Posts: 67
Rep Power: 3 Twilight is on a distinguished road
Well, I've read through the thread, and many others. I think I'm just missing something simple. When I tried the common version I found around the internet, it looks basically like this:

     cout << "Enter a number from 1-5" << endl;
     cin >> choice; // choice is a string I convert to an int

     //various functions do various things, then print stuff.  I need it to wait
     //before clearing the screen and proceeding.

     std::cin.clear(); 
     std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
     std::cout << "Press Enter to continue . . .\n";
     cin.get();

Its my understanding that ignore will remove everything in the input stream, including the first newline it sees. And since there can only be one newline (unless cin is leaving them there, which seems unlikely) from user input, it should ignore the whole stream, and then wait for cin.get(). But it doesn't, and I don't know why.
Twilight is offline   Reply With Quote