Jump to content
  • Advertisement
Sign in to follow this  
lord_balron

Ignoring Successive Chars

This topic is 3638 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

void AskYesNo(string sDisplay, char &pValue)
{
	cout << sDisplay;
	cin.get(pValue).get();
}

So what I'm wondering is, how do you ignore any successive chars if say the user was to input 'yes' instead of 'y'. I added the .get(), and this gets rid of one char, but you can't have to .get()'s.

Share this post


Link to post
Share on other sites
Advertisement
The easiest way would be to switch from character based input and read an entire line at a time with std::getline(). Then check that line's first character.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
The easiest way would be to switch from character based input and read an entire line at a time with std::getline(). Then check that line's first character.


Yeah, I thought of that a minute ago, i was wondering if there was any way to do it with chars, but thanks! I'll try that method.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!