Page 1 of 1

Quick C++ question

Posted: 2008-01-21 10:03am
by The Jester
How do ensure that a variable input via cin is of the same type to which the variable is assigned?

Posted: 2008-01-22 03:47am
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?

Posted: 2008-01-22 07:19am
by Genii Lodus
I think that would be fflush(stdin).