Yes I know that. But since I don't want the file to be accessible at all while the program is running, I should keep it open (whether reading or writing mode) and switch between the modes by using freopen(). something like this:
Originally Posted by Elysia
Would this work (I already started implementing it, but I'm still not sure it'll work).
fopen(file, "r"); // first time
... // read from file and keep file open
freopen(NULL, "w", file); // switch to write mode
... // write to file