Platform is Ubuntu Linux on ARM. I want to write a string to a file, but I want every time to truncate the file and then write the string, i.e. no append.
I have thi
You should not really mix file handle and file descriptor calls like that.
What's almost certainly happening without the fflush is that the some string
is waiting in file handle buffers for delivery to the file descriptor. You then truncate the file descriptor and fclose the file handle, flushing the string, hence it shows up in the file.
With the fflush, some string
is sent to the file descriptor and then you truncate it. With no further flushing, the file stays truncated.