I have opened a file
FILE *fp = fopen("file.txt","r");
fclose(fp);
scenario is that I forgot to assign null to fp
Now I want to check whether this file is open or not using same fp
pointer
You can't. The value of fp
after closing it is indeterminate: http://www.iso-9899.info/n1256.html#7.19.3p4
This means any operation on it results in undefined behaviour.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With