Defering FILE flush to when the file is closed
I want to defer flushing th开发者_开发百科e contents of the FILE* to when fclose is called. In other words, I only want to write to disk when fclose is called and keep buffering the contents until then. Is it possible to do that with FILE* or I need to write my own code?
If you want to buffer (and under no circumstances write to the disk until the file is closed), then your best bet is to write to a buffer in memory (assuming that it will fit in memory, of course), and then write that buffer in one go and then call fclose()
.
精彩评论