请参阅以下代码块,我如何确保 FILE 对象在调用 fclose 之前未关闭?顺便说一句,两次调用 fclose 是否安全?
FILE* f = fopen('test.txt')
//some code here, f may be closed by someone, but they may not set it to NULL
...
/// I want to make sure f is not closed before, how can I do it here?
if(...)
{
fclose(f)
}