Jul 12, 2010 at 6:35am
I'd like some information, stored in a buffer, to be written to the file, when I call close() on the file.
I have looked at FileBuf and pubsetbuf, among others. However, after testing, they are not buffering it (the way I expect them to).
How can I achieve the same as BufferedOutputStream(Java) in C++?
Jul 12, 2010 at 7:34am
fprintf writes are buffered, but the OS may flush the buffer when deemed convenient. Writes to stderr are an exception and are not buffered.
If this bothers you, I suggest creating a secondary buffer, which you then write to the file and fflush().
Jul 19, 2010 at 11:15am
What exactly is the behaviour you are/are not seeing? Are individual characters being written to the file with every write?
Jul 19, 2010 at 2:32pm
Last edited on Jul 19, 2010 at 2:32pm