fclose 中文man页面

系统
函数 fclose 将名为 stream 的流与它底层关联的文件或功能集合断开。如果流曾用作输出,任何缓冲的数据都将首先被写入,使用 fflush(3) 。

NAME

fclose - 关闭流  

SYNOPSIS 总览

#include <stdio.h>

int fclose(FILE *stream);  

DESCRIPTION 描述

函数 fclose 将名为 stream 的流与它底层关联的文件或功能集合断开。如果流曾用作输出,任何缓冲的数据都将首先被写入,使用 fflush(3) 。  

RETURN VALUE 返回值

成功执行返回 0,否则返回 EOF 并设置全局变量 errno 来指示错误发生。任何一种情况下,对流再进行存取 (包括再次调用 fclose()) 都会带来未定义的结果。  

ERRORS

EBADF
stream 底层的文件描述符是无效的。

函数 fclose 也可能失败并置 errnoclose(2), write(2) 或 fflush(3) 指定的值。  

NOTES 要点

注意 fclose 仅仅刷新用户空间的由 C 库提供的缓冲。要保证数据被物理地存储到磁盘上,必须也刷新内核缓冲。例如,使用 sync(2) 或 fsync(2).  

CONFORMING TO 标准参考

函数 fclose 遵循 ANSI X3.159-1989 (``ANSI C'') 标准。  

SEE ALSO 参见

close(2), fcloseall(3), fflush(3), fopen(3), setbuf(3)

#p#

NAME

fclose - close a stream  

SYNOPSIS

#include <stdio.h>

int fclose(FILE *stream);  

DESCRIPTION

The fclose function dissociates the named stream from its underlying file or set of functions. If the stream was being used for output, any buffered data is written first, using fflush(3).  

RETURN VALUE

Upon successful completion 0 is returned. Otherwise, EOF is returned and the global variable errno is set to indicate the error. In either case any further access (including another call to fclose()) to the stream results in undefined behaviour.  

ERRORS

EBADF
The filedescriptor underlying stream is not valid.

The fclose function may also fail and set errno for any of the errors specified for the routines close(2), write(2) or fflush(3).  

NOTES

Note that fclose only flushes the user space buffers provided by the C library. To ensure that the data is physically stored on disk the kernel buffers must be flushed too, e.g. with sync(2) or fsync(2).  

CONFORMING TO

The fclose function conforms to ANSI X3.159-1989 (``ANSI C'').  

SEE ALSO

close(2), fcloseall(3), fflush(3), fopen(3), setbuf(3)

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-08-25 15:39:42

fcloseall中文man

2011-08-25 15:00:15

cfgetispeed中文man

2011-08-19 18:35:50

issue中文man

2011-08-25 17:03:51

pclose中文man

2011-08-25 17:40:25

setvbuf中文man

2011-08-23 14:21:16

poweroff中文man

2011-08-24 15:52:59

intro中文man

2011-08-23 13:40:31

2011-08-25 17:24:54

puts中文man

2011-08-25 18:34:55

ungetc中文man

2011-08-23 10:03:40

useradd中文man

2011-08-23 10:29:02

chpasswd中文man

2011-08-23 10:34:22

convertquot中文man

2011-08-23 15:39:34

rpmbuild中文man

2011-08-24 15:48:38

INSERT中文man

2011-08-25 09:40:49

UPDATE中文man
点赞
收藏

51CTO技术栈公众号