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
If you want to literally "truncate the file then write", then it's sufficient to:
f=fopen("/home/user1/refresh.txt","w");
fputs("some string",f);
fclose(f);
Opening the file in the mode w
will truncate it (as opposed to mode a
which is for appending to the end).
Also calling fclose
will flush the output buffer so no data gets lost.