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

查看所有标签

R Cookbook

R Cookbook

Paul Teetor / O'Reilly Media / 2011-3-22 / USD 39.99

With more than 200 practical recipes, this book helps you perform data analysis with R quickly and efficiently. The R language provides everything you need to do statistical work, but its structure ca......一起来看看 《R Cookbook》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

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

URL 编码/解码