Skip to main content
GameDev.net gamedev.net
🔒 Locked

cin.ignore ?

Started by Just_starting Oct 7, 2004 at 7:56 PM 1 replies 500+ views
Original Post
Just_starting
Just_starting
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?
C-Junkie
C-Junkie
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.
Just_starting
Just_starting
That was way to easy I owe you a Soda

Thanks

Programming is by far the most frustrating yet the most rewarding class I have taken

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.