The condition of a stream is equivalent to !fail()
, which means set either failbit
or badbit
will terminate the loop. For example, errors list below will terminate the loop:
- System-level failure. (Set the
badbit
) Such as an unrecoverable r/w error. - Recoverable error. (Set the
failbit
) Such as reading a character when numeric data expected. - Reaching end-of-file. (Set both the
eofbit
andfailbit
)