First of all remember that all input operator functions (>>
) returns the input stream, and secondly remember that a stream can be used as a boolean condition.
This means you can do e.g.
std::string string1, string2;
double point1, point2, point3;
if (some_input_stream >> string1 >> string2 >> point1 >> point2 >> point3)
{
// All is okay
}
else
{
// One of the input operations failed
}
To know exactly which input operation failed, you can do them one at a time.