Check if all values were successfully read from std::istream
Let's say I have a file that has 100 text If I try reading 2 numbers using ifstream, it would fail because text is not a number. Using fscanf I'll know it failed by checking its return code: if (2 != fscanf(f, "%d %d", &a, &b)) printf("failed"); But when using iostream instead of stdio, how do I know it failed? Its actually as (if not more) simple: ifstream ifs(filename); int a, b; if (!(ifs >> a >> b)) cerr << "failed"; Get used to that format, by the way. as it comes in very handy (even more-so for continuing positive progression through loops). If one' using GCC with -std=c++11 or -std=c+