JH> if an char value is inputed into a cin << input, where input is defi
JH> a float my program goes "crazy" All inputs after the cin .. are not
JH> accepted. Is there a way to get around this? I plan to have a window
JH> and say "Invalid amount please redo"
JH> I have tried:
JH> if (input!=float) cout <<"invalid";
JH> ...but the program still exectued the same.
float input;
if (cin << input)
// do your stuff here
else
cout << "invalid";
should work (streams have implicit conversion to a boolean type that
can be used like this).
If you are programming under Windows 95, there might also be a problem
with floating point stream I/O when some older version of the System
Agent is running.
Thomas
---
þ MM 1.0 #0113 þ I just got a new car for my girlfriend....Great trade...
---------------
* Origin: McMeier & Son BBS (2:301/138)
|