stdio 中文man页面

系统
标注 I/O 库函数提供了一个简单而有效的,带缓冲的流输出输出接口。输入和输出被映射为逻辑的数据流,物理的 I/O 特性则被隐藏起来。库中包含的函数与宏列在下面;更多信息可以从独立的 man 手册页中得到。

NAME

stdio - 标准输入输出库函数  

SYNOPSIS 总览

#include <stdio.h>

FILE *stdin;
FILE *stdout;
FILE *stderr;  

DESCRIPTION 描述

标注 I/O 库函数提供了一个简单而有效的,带缓冲的流输出输出接口。输入和输出被映射为逻辑的数据流,物理的 I/O 特性则被隐藏起来。库中包含的函数与宏列在下面;更多信息可以从独立的 man 手册页中得到。

将一个流关联到一个外部文件 (可能是一个物理设备) 的方法是打开 ( opening ) 这个文件,其中可能牵涉到创建一个新文件。创建已有的文件使得文件中已有的内容被丢弃。如果文件支持定位请求 (例如磁盘文件;但终端不是这样),那么一个与文件关联的定位标记 ( file position indicator ) 被定位到文件的起始 (0 字节),除非以追加模式打开文件。使用追加模式时,究竟定位标记位于文件的开始还是结束是没有指定的。定位标记由后续的读、写和定位请求来维护。从流中输入时,就如同字符是连续地成功调用了函数 fgetc(3) 而读入的;产生输出时,就如同所有字符是连续地成功调用了函数 fputc(3) 而输出的。

将一个流与一个与之关联的文件断开的办法是关闭 ( closing ) 这个文件。在流与文件断开之前,输出流被刷新 (任何未写入的缓冲的内容都被传输给主机环境)。在文件被关闭之后,指向 FILE 对象的指针的值是不确定的 (无用数据)。

一个文件可以继续被相同的或是不同的程序实体再次打开,它的内容可以被恢复或者修改 (如果它可以被重定位到文件开始的话)。如果 main 函数返回到它最初的调用者,或者调用了函数 exit(3) ,在程序终止前,所有打开的文件都将被关闭 (因此所有的输出流都被刷新)。其他终止程序的方法,例如 abort(3) 不会进行正常的关闭文件操作。

在程序启动时,会预先定义三个文本流,它们不需要显式地打开 --- 标准输入 (用于读入常规内容),--- 标准输出 (用于输出常规内容),以及 标准错误 (用于输出诊断信息)。这些流的缩写是 stdin,stdoutstderr 。在打开时,标准错误流不会完全缓冲;当且仅当流不是一个交互的设备时,标准输入和标准输出流才被完全缓冲。

指向终端设备的输出流总是默认使用行缓冲;未定的输出总是在指向一个终端设备的输入流被读取时自动被写入。如果在一个输出终端上打印了一行的一部分,然后运行了大量的计算后,应当在退出和计算前 fflush(3) 标准输出,使得输出可以显示出来。(?)

标准输入输出库 stdio 是函数库 libc 的一部分,需要时可以被编译器 cc(1) 和 pc(1) 自动加载。下列手册页的 SYNOPSIS 总览 段落会指出要包含哪些文件,函数定义的格式,以及它们受到哪些外部变量的影响。

下列为已定义的宏;如果不用 #undef 取消这些名称的当前定义的话,是不能重新使用它们的: BUFSIZ, EOF, FILENAME_MAX, FOPEN_MAX, L_cuserid, L_ctermid, L_tmpnam, NULL, SEEK_END, SEEK_SET, SEE_CUR, TMP_MAX, clearerr, feof, ferror, fileno, fropen, fwopen, getc, getchar, putc, putchar, stderr, stdin, stdout. 另外,还有与这些宏的功能对应的,函数形式的版本 feof, ferror, clearerr, fileno, getc, getchar, putc, 和 putchar ,在显式地取消宏的定义时,可以使用它们。  

LIST OF FUNCTIONS 函数列表

Function 函数
Description 描述
clearerr
检测并重置流状态
fclose
关闭流
fdopen
打开流
feof
检测并重置流状态
ferror
检测并重置流状态
fflush
刷新流
fgetc
从输入流中获取下一个字符或词
fgetpos
重定位流
fgets
从流中获取一行
fileno
返回流参数的整数形式的描述符
fopen
打开流
fprintf
按照格式输出常规内容
fpurge
刷新流
fputc
向流输出一个字符或词
fputs
向流输出一行
fread
二进制输入/输出
freopen
打开流
fropen
打开流
fscanf
按照格式输入常规内容
fseek
重定位流
fsetpos
重定位流
ftell
重定位流
fwrite
二进制输入/输出
getc
从输入流中获取下一个字符或词
getchar
从输入流中获取下一个字符或词
gets
从流中获取一行
getw
从输入流中获取下一个字符或词
mktemp
创建 (***的) 临时文件名
perror
系统错误消息
printf
按照格式输出常规内容
putc
向流输出一个字符或词
putchar
向流输出一个字符或词
puts
向流输出一行
putw
向流输出一个字符或词
remove
删除目录项
rewind
重定位流
scanf
按照格式输入常规内容
setbuf
流缓冲操作
setbuffer
流缓冲操作
setlinebuf
流缓冲操作
setvbuf
流缓冲操作
sprintf
按照格式输出常规内容
sscanf
按照格式输入常规内容
strerror
系统错误消息
sys_errlist
系统错误消息
sys_nerr
系统错误消息
tempnam
临时文件控制
tmpfile
临时文件控制
tmpnam
临时文件控制
ungetc
向输入流中退回字符
vfprintf
按照格式输出常规内容
vfscanf
按照格式输入常规内容
vprintf
按照格式输出常规内容
vscanf
按照格式输入常规内容
vsprintf
按照格式输出常规内容
vsscanf
按照格式输入常规内容

CONFORMING TO 标准参考

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

SEE ALSO 参见

open(2), close(2), read(2), write(2), stdout(3)

#p#

NAME

stdio - standard input/output library functions  

SYNOPSIS

#include <stdio.h>

FILE *stdin;
FILE *stdout;
FILE *stderr;  

DESCRIPTION

The standard I/O library provides a simple and efficient buffered stream I/O interface. Input and output is mapped into logical data streams and the physical I/O characteristics are concealed. The functions and macros are listed below; more information is available from the individual man pages.

A stream is associated with an external file (which may be a physical device) by opening a file, which may involve creating a new file. Creating an existing file causes its former contents to be discarded. If a file can support positioning requests (such as a disk file, as opposed to a terminal) then a file position indicator associated with the stream is positioned at the start of the file (byte zero), unless the file is opened with append mode. If append mode is used, it is unspecified whether the position indicator will be placed at the start or the end of the file. The position indicator is maintained by subsequent reads, writes and positioning requests. All input occurs as if the characters were read by successive calls to the fgetc(3) function; all output takes place as if all characters were written by successive calls to the fputc(3) function.

A file is disassociated from a stream by closing the file. Output streams are flushed (any unwritten buffer contents are transferred to the host environment) before the stream is disassociated from the file. The value of a pointer to a FILE object is indeterminate after a file is closed (garbage).

A file may be subsequently reopened, by the same or another program execution, and its contents reclaimed or modified (if it can be repositioned at the start). If the main function returns to its original caller, or the exit(3) function is called, all open files are closed (hence all output streams are flushed) before program termination. Other methods of program termination, such as abort(3) do not bother about closing files properly.

At program startup, three text streams are predefined and need not be opened explicitly --- standard input (for reading conventional input), --- standard output (for writing conventional input), and standard error (for writing diagnostic output). These streams are abbreviated stdin,stdout and stderr. When opened, the standard error stream is not fully buffered; the standard input and output streams are fully buffered if and only if the streams do not to refer to an interactive device.

Output streams that refer to terminal devices are always line buffered by default; pending output to such streams is written automatically whenever an input stream that refers to a terminal device is read. In cases where a large amount of computation is done after printing part of a line on an output terminal, it is necessary to fflush(3) the standard output before going off and computing so that the output will appear.

The stdio library is a part of the library libc and routines are automatically loaded as needed by the compilers cc(1) and pc(1). The SYNOPSIS sections of the following manual pages indicate which include files are to be used, what the compiler declaration for the function looks like and which external variables are of interest.

The following are defined as macros; these names may not be re-used without first removing their current definitions with #undef: BUFSIZ, EOF, FILENAME_MAX, FOPEN_MAX, L_cuserid, L_ctermid, L_tmpnam, NULL, SEEK_END, SEEK_SET, SEE_CUR, TMP_MAX, clearerr, feof, ferror, fileno, fropen, fwopen, getc, getchar, putc, putchar, stderr, stdin, stdout. Function versions of the macro functions feof, ferror, clearerr, fileno, getc, getchar, putc, and putchar exist and will be used if the macros definitions are explicitly removed.  

LIST OF FUNCTIONS

Function
Description
clearerr
check and reset stream status
fclose
close a stream
fdopen
stream open functions
feof
check and reset stream status
ferror
check and reset stream status
fflush
flush a stream
fgetc
get next character or word from input stream
fgetpos
reposition a stream
fgets
get a line from a stream
fileno
return the integer descriptor of the argument stream
fopen
stream open functions
fprintf
formatted output conversion
fpurge
flush a stream
fputc
output a character or word to a stream
fputs
output a line to a stream
fread
binary stream input/output
freopen
stream open functions
fropen
open a stream
fscanf
input format conversion
fseek
reposition a stream
fsetpos
reposition a stream
ftell
reposition a stream
fwrite
binary stream input/output
getc
get next character or word from input stream
getchar
get next character or word from input stream
gets
get a line from a stream
getw
get next character or word from input stream
mktemp
make temporary file name (unique)
perror
system error messages
printf
formatted output conversion
putc
output a character or word to a stream
putchar
output a character or word to a stream
puts
output a line to a stream
putw
output a character or word to a stream
remove
remove directory entry
rewind
reposition a stream
scanf
input format conversion
setbuf
stream buffering operations
setbuffer
stream buffering operations
setlinebuf
stream buffering operations
setvbuf
stream buffering operations
sprintf
formatted output conversion
sscanf
input format conversion
strerror
system error messages
sys_errlist
system error messages
sys_nerr
system error messages
tempnam
temporary file routines
tmpfile
temporary file routines
tmpnam
temporary file routines
ungetc
un-get character from input stream
vfprintf
formatted output conversion
vfscanf
input format conversion
vprintf
formatted output conversion
vscanf
input format conversion
vsprintf
formatted output conversion
vsscanf
input format conversion

CONFORMING TO

The stdio library conforms to ANSI X3.159-1989 (``ANSI C'').  

SEE ALSO

open(2), close(2), read(2), write(2), stdout(3)

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

2011-08-15 10:21:09

man中文man

2011-08-24 16:48:36

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-08-11 15:03:21

ACCESS中文man

2011-08-16 10:59:16

pwconv中文man

2011-08-18 19:02:43

environ中文man

2011-08-25 17:43:07

snprintf中文man

2011-08-19 18:30:52

ipc中文man

2011-08-24 15:35:52

hier中文man

2011-08-25 17:18:07

putc中文man

2011-08-15 13:53:19

stat中文man

2011-08-16 10:10:58

setup中文man

2011-08-25 15:24:31

execlp中文man

2011-08-25 18:24:12

termios中文man

2011-08-15 18:06:07

restore中文man

2011-08-24 17:26:35

reindex中文man

2011-08-25 16:55:26

gets中文man

2011-08-15 15:45:04

xpdf中文man

2011-08-24 17:06:42

NOTIFY中文man
点赞
收藏

51CTO技术栈公众号