I could not find pretty much any information on this. Whether and if so, under what circumstances, can eofbit be set (meaning ofstream_instance.eof() is true )?
I am more interested in an independent ofstream, one that is not associated with an ifstream within some fstream, so that the "shared" eofbit can't be set by the ifstream (if something like that is possible).
If I simply write to a file and there is no space on disk or operation system does not provide another space for the writing, then I'd expect just only either failbit or badbit to be set, but reaching end of file while writing to it does not make sense to me. However no discussion on this I was able to find.
eof
bit instd::ofstream
. If youclose()
thestd::ofsteam
and it doesn't fail I would assume that output was successfully. Though, I somewhere read that this is true "above" OS level only. To grant this for the harddisk may take even more effort (beyond std C++) e.g. doing anfsync()
. (My stomache was right - found:) SO: How do I ensure data is written to disk before closing fstream? – Scheff's Cat