void clear (iostate state = goodbit);
iostate value (member constant) | indicates | functions to check state flags | ||||
---|---|---|---|---|---|---|
good() | eof() | fail() | bad() | rdstate() | ||
goodbit | No errors (zero value iostate) | true | false | false | false | goodbit |
eofbit | End-of-File reached on input operation | false | true | false | false | eofbit |
failbit | Logical error on i/o operation | false | false | true | false | failbit |
badbit | Read/writing error on i/o operation | false | false | true | true | badbit |
|
|
myfile
is open for input operations, but we perform an output operation on it, so failbit
is set. The example calls then clear in order to remove the flag and allow further operations like getline to be attempted on myfile
.