"Opposite" of cin.fail()?
Is there any way to detect when cin succeeds, like how cin.fail() looks for when it, well... fails?
Yes. There are several ways to test C++ streams.
1 2 3 4 5 6 7 8 9 10 11 12 13
|
if(!cin.fail())
..,
if(cin.good())
...
if(!cin)
...
if(cin)
...
| |
Normally simply
if (cin)
.
Often, rather than doing say:
1 2 3
|
int n;
cin >> n;
if (cin)
| |
one would prefer this:
Last edited on
Alright, that makes sense. Thanks!
Topic archived. No new replies allowed.