Jump to content
  • Advertisement
Sign in to follow this  
Just_starting

cin.ignore ?

This topic is 5029 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

Quick question: when trying to ignore all charicters aside from the first entered in ex: cin >> "y or n"; user enters "yhuo...." I just want the y and I need everything else "flushed" What is happening is: cin >> "y or n"; user enters "yhuo...." cin >> "h or r"; 'h' from the last entry is being stored and used for this question. By adding this line after a cin >> choice; cin.ignore(256,' '); All inputs are ignored until a whitespace is entered (cplusplus.com) tutorial How can I apply this concept to this circumstance?

Share this post


Link to post
Share on other sites
Advertisement
Um....

sound like you have your answer already.

you'd ignore until '\n' to get rid of the rest of whatever the user typed, though.

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!