![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Programmer
Join Date: Apr 2006
Location: Calgary, Alberta
Posts: 67
Rep Power: 3
![]() |
But there wasn't anything past that. At the previous prompt it would be a single digit input, and a newline.
|
|
|
|
|
|
#22 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Use a debugger. Your voodoo won't be effective. Or, you could just read the thread and comprehend what it's saying, and read the descriptions of the functions, and use the facts.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#23 |
|
Programmer
Join Date: Apr 2006
Location: Calgary, Alberta
Posts: 67
Rep Power: 3
![]() |
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. |
|
|
|
|
|
#24 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Wrong about the number of newlines. If the user types 123<ENTER> five times with no intervening reads of the stream, they're all in there. I won't say you're making a mountain out of a molehill, but you're certainly ignoring all the bulldozers sitting around idle.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Slackware installation guide for Linux beginners | coldDeath | Coder's Corner Lounge | 104 | Jul 29th, 2007 4:40 AM |
| please help me to compile | cwl157 | C++ | 37 | Mar 6th, 2006 6:12 PM |
| replace space with ' * ' | TecBrain | C++ | 15 | Apr 13th, 2005 12:32 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |
| Whats wrong... | brandcolt | C++ | 6 | Mar 1st, 2005 10:37 AM |