Quick C++ question

GEC: Discuss gaming, computers and electronics and venture into the bizarre world of STGODs.

Moderator: Thanas

Post Reply
User avatar
The Jester
Padawan Learner
Posts: 475
Joined: 2005-05-30 08:34am
Location: Japan

Quick C++ question

Post by The Jester »

How do ensure that a variable input via cin is of the same type to which the variable is assigned?
User avatar
The Jester
Padawan Learner
Posts: 475
Joined: 2005-05-30 08:34am
Location: Japan

Post by The Jester »

Also need to use cin.clear(); to prevent cin from returning an error.

Another question, if one is using C and scanf, how does one clear the input buffer when encountering a similar problem?
User avatar
Genii Lodus
Padawan Learner
Posts: 199
Joined: 2005-06-06 09:34am

Post by Genii Lodus »

I think that would be fflush(stdin).
Post Reply