program skips over user input?

G'day all,

I am so close to finishing this program of games, but I'm running into some issues while debugging it.

I've attached the google drive folder since there are several files (ignore the ones with [conflict], etc), sorry about that.

First, I have the main menu using a switch to select the game. The default was set to exit. If initially when immediately opening the program you put in for say, a letter, it would exit like its supposed to. But if you went and played any of the games ], went back to the main screen, and entered a letter then, it would crash. I've put in a testing line to make sure that you enter a number, and not anything else.

Now however, if you play a game and then want to go back to the main menu, it will simply skip over waiting for your response and close the program. The same thing happens in the slot machine, I want to have it spin the slot machine by pressing enter, but it simply skips over the input, and I'm not sure why.
If anyone has any suggestions on making any of the program cleaner/more efficient, by all means, please do as I'm still a beginner.

Thanks!
Wuubb

https://drive.google.com/folderview?id=0BxrGevbsvIgnVmx6YTFnY3lKQlk&usp=sharing
anytime you use a getline(cin,strName) ... put a cin.ignore(80,'\n'); right after.

This effectively clears the input buffer that may still be holding a Return key press from your previous input.

there are several ways to do this but the above is what I typically do, not sure if it is considered 'correct'
anytime you use a getline(cin,strName) ... put a cin.ignore(80,'\n'); right after.

This effectively clears the input buffer that may still be holding a Return key press from your previous input.

there are several ways to do this but the above is what I typically do, not sure if it is considered 'correct'


Thanks for the info, but could you explain to me why you put 80, '\n' in the parenthesis. I know what '\n' does, but I guess im not understanding what the purpose of both of those items is. I just want to understand how it works.
Topic archived. No new replies allowed.