0

Hi,
I am using a FILE to write a protocol of the program execution which I will be using in case of crashes.
Whenever I write a message to the file I open it

if ((mfdprot = fopen(protfile, "a")) == NULL)	{

after that I close it:

close(mfdprot);

No matter what I tried the file is only written when the program terminates normally.
I also tried to use sync but nothing changed.

Any help is appreciated.
Heinz

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by heinzw
0

>>close(mfdprot);
You probably meant fclose(mfdprot)

Sounds like your operating system is buffering up the data. Try adding fflush() before fclose().

0

>>close(mfdprot);
You probably meant fclose(mfdprot)

Sounds like your operating system is buffering up the data. Try adding fflush() before fclose().

Thank you for your reply!

I just found fflush and it works.

Thanks again.
Heinz

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.