Suppose I have the following program:
#include <stdio.h>
int main () {
FILE * pFile;
pFile = fopen ("myfile.txt","r");
fclose (pFile);
return 0;
}
I have never seen a program that does free(pFile)after closing a file descriptor. Why is this?
I know that since it fclose()does not receive a pointer to pFile, it does not actually free up pointer memory. I got the impression that pointers should always free up their memory if they point to dynamically allocated memory. Why does anyone free()need a file pointer?
source
share