文件的打开、关闭、读和写函数(fopen()、fclose()、fgets()、getc()等等)、printf()函数系列和setvbuf()函数都需要它。
互联网摘选
它演示了对一些系统调用和C库函数的适当使用,其中包括fopen、fclose、access、setvbuf、perror、strerror和popen。
互联网摘选
While the C standard doesn't specify what happens without the fclose(), it's likely to leak memory.
在没有fclose()的情况下,C标准不能指定发生的情况时,很可能是内存泄漏。
互联网摘选
当然,除fclose以外,您可能已经对这些函数的返回值都进行了处理。
互联网摘选
使用fclose时,即使文件处理未正常关闭,也不会执行什么操作,因此通常不必检查fclose的返回值。
互联网摘选
The fgets, fgetss, fread, fscanf, and fclose functions also return False on error.
fscanf和fclose函数在出错时也返回False。
互联网摘选