From the documentation for std :: fflush ( http://en.cppreference.com/w/cpp/io/c/fflush ):
Makes the stream of the output file synchronize with the actual contents of the file. The behavior is undefined if the given stream is equal to the input type or if the given stream has the update type, but the last I / O operation was not an output operation.
I need to call fflush on a file in order to be able to get its size on disk, but I don't know if the last operation was entered or output. Is there a way to check if the last operation in FILE was output in order to prevent undefined behavior?
source share