FCLOSE检查返回值是否 [英] fclose return value check
问题描述
是不是需要检查FCLOSE的返回值?如果我们已经成功打开的文件,什么是机会,它可能无法关闭?
Is it required to check the return value of fclose? If we have successfully opened a file, what are the chances that it may fail to close?
谢谢!
问候,
周杰伦
Regards, Jay
推荐答案
在 FWRITE
来一个文件,它实际上可能没有写任何东西,它可能停留在一个缓冲区(File对象中)。调用 fflush
实际上它写入磁盘。 这个操作可能会失败,例如,如果你刚跑出的磁盘空间,或者有一些其他的I / O错误。
When you fwrite
to a file, it may not actually write anything, it may stay in a buffer (inside the FILE object). Calling fflush
would actually write it to disk. That operation may fail, for example if you just ran out of disk space, or there is some other I/O error.
FCLOSE
刷新缓冲区含蓄了,所以它可能会失败出于同样的原因。
fclose
flushes the buffers implicitly too, so it may fail for the same reasons.
这篇关于FCLOSE检查返回值是否的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!