Input/ Output with files Flashcards
what is difference between ofstream, ifstream and fstream
ofstream: stream class to write on files
ifstream: stream class to read from files
fstream: stream class to both read and write from/to files
Mention some open file modes
ios:in - open for input operations
ios:out - open for output operations
ios:binary - open in binary mode
ios:ate -set the initial position at the end of the file.
ios:app - all output operations are performed at the end of the file.
ios:trunk - if the file for output operations, it clears the contents of the file before writing data to it.
Mention some flags in I/O
bad()
fail()
eof()
good()
clear()
What is the function of the eof()
Returns true if a file open for reading has reached the end.
What is the difference bewteen bad() and fail()
bad() returns true if a reading or writing operation fails while fail() returns true in the same case as bad() but also in the case that a format error happens
what is the function of clear()
Can be used to reset the state flags