I have separate locations in my C program where I call fopen
, fwrite
and fclose
.
When some conditions are met, I want to delete the file I worked on instead of calling fclose
on it. However, by the time I reach fclose, it isn't trivial to recreate the file name I used when calling fopen
so using remove
isn't practical.
Is there something I can do instead or before calling fclose
so that in effect the file I opened with fopen
and used fwrite
on will not show up on disk in the end?
E.g.
f = fopen(filename,"wt");
...
fwrite(f,...)
...
// How can I undo here the effect of fopen and fwrite without knowledge of filename?