【发布时间】:2013-02-28 01:49:08
【问题描述】:
请看下面的代码块,我如何确保一个 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)
}
【问题讨论】:
-
你用的是什么编译器?
-
@Aniket 我正在使用 gcc