I wrote o program which have to work in inf while loop. In the loop, program have to save some datas to file and close this file. In the loop there is a sleep function which sleep program for 10 seconds. Then I want to check what is in the file but it is empty. If the program run without loop everything is OK
The full code is rather huge so I include a short version
main()
{
FILE* fp;
while(1)
{
fp=fopen(SAVE_FILE, "awt");
if(fp==NULL)
{
printf("Error while opening the save file \n");
}
fprintf(fp, "%s",'this is saved text');
fclose(fp);
sleep(10);
}
}
Have any idea how to close this file correctly to be able to read datas while sleep functiion?
(This is running on linux)