Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 20th, 2007, 4:53 PM   #21
Twilight
Programmer
 
Join Date: Apr 2006
Location: Calgary, Alberta
Posts: 67
Rep Power: 3 Twilight is on a distinguished road
But there wasn't anything past that. At the previous prompt it would be a single digit input, and a newline.
Twilight is offline   Reply With Quote
Old Apr 20th, 2007, 5:26 PM   #22
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
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
Old Apr 20th, 2007, 10:32 PM   #24
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:46 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC