I want “something” to appear in “test2.txt” right after the call to fwrite (before sleep finishes). If I use fclose it works, but I dont want to use fclose because it will release my flock. I read that fflush would work for this but nothing happens when I use it. Anyone know what the problem is ?
@qrazyneo1 when you post code in the forum, you need to format it. To do so you can either select all the code and click the </> button, or type 3 backticks ``` on a separate line both before and after the block of code.
Using ftruncate after fflush solved it. Fflush not even necessary. Seems strange that ftruncate does the job of fflush (despite it’s designed for something else) and weird that fflush doesn’t flush at all.