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

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

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

>>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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.