int fclose(FILE *stream)
描述 (Description)
C库函数int fclose(FILE *stream)关闭流。 刷新所有缓冲区。
声明 (Declaration)
以下是fclose()函数的声明。
int fclose(FILE *stream)
参数 (Parameters)
stream - 这是指向FILE对象的指针,指定要关闭的流。
返回值 (Return Value)
如果流成功关闭,则此方法返回零。 失败时,返回EOF。
例子 (Example)
以下示例显示了fclose()函数的用法。
#include <stdio.h>
int main () {
FILE *fp;
fp = fopen("file.txt", "w");
fprintf(fp, "%s", "This is iowiki.com");
fclose(fp);
return(0);
}
让我们编译并运行上面的程序,它将创建一个文件file.txt ,然后它会写下面的文本行,最后它将使用fclose()函数关闭文件。
This is iowiki.com