In addition to good(), which checks whether the stream is ready
for input/output operations, other member functions exist to check for
specific states of a stream (all of them return a bool value):
In order to reset the state flags checked by any of these member functions we have just seen we can use the member function clear(), which takes no parameters.
- bad()
- Returns true if a reading or writing operation fails. For example in the case that we try to write to a file that is not open for writing or if the device where we try to write has no space left.
- fail()
- Returns true in the same cases as bad(), but also in the case that a format error happens, like when an alphabetical character is extracted when we are trying to read an integer number.
- eof()
- Returns true if a file open for reading has reached the end.
- good()
- It is the most generic state flag: it returns false in the same cases in which calling any of the previous functions would return true.
In order to reset the state flags checked by any of these member functions we have just seen we can use the member function clear(), which takes no parameters.
Comments
Post a Comment
https://gengwg.blogspot.com/