SK95
Subscriber

fp in the function header is a pointer to a file which is already open, therefore using fopen can lead to undefined behaviour. Try to use this code:

DEFINE_RW_FILE(writer, fp)


{


   fprintf(fp, %d, kount);


}