C 库函数 - fclose()

C 语言教程 · 2019-02-23 13:29:16

描述

C 库函数 int fclose(FILE *stream) 关闭流 stream。刷新所有的缓冲区。

声明

下面是 fclose() 函数的声明。

int fclose(FILE *stream)

参数

  • stream -- 这是指向 FILE 对象的指针,该 FILE 对象指定了要被关闭的流。

返回值

如果流成功关闭,则该方法返回零。如果失败,则返回 EOF。

实例

下面的实例演示了 fclose() 函数的用法。

#include <stdio.h>

int main()
{
   FILE *fp;
 
   fp = fopen("file.txt", "w");

   fprintf(fp, "%s", "这里是 codercto.com");
   fclose(fp);
   
   return(0);
}

让我们编译并运行上面的程序,这将创建一个文件 file.txt,然后写入下面的文本行,最后使用 fclose() 函数关闭文件。

这里是 codercto.com

点击查看所有 C 语言教程 文章: https://www.codercto.com/courses/l/17.html

查看所有标签

Release It!

Release It!

Michael T. Nygard / Pragmatic Bookshelf / 2007-03-30 / USD 34.95

“Feature complete” is not the same as “production ready.” Whether it’s in Java, .NET, or Ruby on Rails, getting your application ready to ship is only half the battle. Did you design your system to......一起来看看 《Release It!》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

在线进制转换器
在线进制转换器

各进制数互转换器

URL 编码/解码
URL 编码/解码

URL 编码/解码