📄 stdio.3
字号:
.\" Copyright (c) 1980 Regents of the University of California..\" All rights reserved. The Berkeley software License Agreement.\" specifies the terms and conditions for redistribution..\".\" @(#)stdio.3s 6.2 (Berkeley) 5/13/86.\".TH STDIO 3 "May 13, 1986".UC 4.SH NAMEstdio \- standard buffered input/output package.SH SYNOPSIS.nf.ft B#include <stdio.h>FILE *stdin;FILE *stdout;FILE *stderr;.ft R.fi.SH DESCRIPTIONThe functions in the standard I/O library constitute a user-level bufferingscheme. The in-line macros.B getcand.BR putc (3)handle characters quickly. The higher level routines.BR gets ,.BR fgets ,.BR scanf ,.BR fscanf ,.BR fread ,.BR puts ,.BR fputs ,.BR printf ,.BR fprintf ,.BR fwriteall use.B getcand.BR putc ;they can be freely intermixed..PPA file with associated buffering is called a.IR stream ,and is declared to be a pointer to a defined type.SM.BR FILE ..BR Fopen (3)creates certain descriptive data for a streamand returns a pointer to designate the stream in all further transactions.There are three normally open streams with constant pointers declared inthe include file and associated with the standard open files:.TP 10n.B stdinstandard input file.br.ns.TP.B stdoutstandard output file.br.ns.TP.B stderrstandard error file.PPA constant `pointer'.SM.B NULL(0)designates no stream at all..PPAn integer constant.SM.B EOF(\-1) is returned upon end of file or error by integer functions thatdeal with streams..PPAny routine that uses the standard input/output packagemust include the header file.RI < stdio.h >of pertinent macro definitions.The functions and constants mentioned in the standard I/O manual pagesare declared in the include file and need no further declaration.The constants, and the following `functions' areimplemented as macros; redeclaration of these names is perilous:.BR clearerr ,.BR getc ,.BR getchar ,.BR putc ,.BR putchar ,.BR feof ,.BR ferror ,.BR fileno ..SH "SEE ALSO".BR open (2),.BR close (2),.BR read (2),.BR write (2),.BR fclose (3),.BR ferror (3),.BR fopen (3),.BR fread (3),.BR fseek (3),.BR getc (3),.BR gets (3),.BR printf (3),.BR putc (3),.BR puts (3),.BR scanf (3),.BR setbuf (3),.BR ungetc (3)..SH DIAGNOSTICSThe value.SM.B EOFis returned uniformly to indicate that a.SM.B FILEpointer has not been initialized with.BR fopen ,input (output) has been attempted on an output (input) stream, or a.SM.B FILEpointer designates corrupt or otherwise unintelligible.SM.B FILEdata..PPFor purposes of efficiency, this implementation of the standard libraryhas been changed to line buffer output to a terminal by default and attemptsto do this transparently by flushing the output whenever a .BR read (2)from the standard input is necessary. This is almost always transparent,but may cause confusion or malfunctioning of programs which usestandard i/o routines but use.BR read (2)themselves to read from the standard input..PPIn cases where a large amount of computation is done after printingpart of a line on an output terminal, it is necessary to.BR fflush (3)the standard output before going off and computing so that the outputwill appear..SH BUGSThe standard buffered functions do not interact well with certain otherlibrary and system functions, especially \fBfork\fP and \fBabort\fP..SH "LIST OF FUNCTIONS".sp 2.nf.ta \w'setlinebuf'u+2n +\w'setbuf(3)'u+10n\fBName\fP \fBAppears on Page\fP \fBDescription\fP.ta \w'setlinebuf'u+4n +\w'setbuf(3)'u+4n.sp 5pclearerr ferror(3) stream status inquiriesfclose fclose(3) close or flush a streamfdopen fopen(3) open a streamfeof ferror(3) stream status inquiriesferror ferror(3) stream status inquiriesfflush fclose(3) close or flush a streamfgetc getc(3) get character or word from streamfgets gets(3) get a string from a streamfileno ferror(3) stream status inquiriesfopen fopen(3) open a streamfprintf printf(3) formatted output conversionfputc putc(3) put character or word on a streamfputs puts(3) put a string on a streamfread fread(3) buffered binary input/outputfreopen fopen(3) open a streamfscanf scanf(3) formatted input conversionfseek fseek(3) reposition a streamftell fseek(3) reposition a streamfwrite fread(3) buffered binary input/outputgetc getc(3) get character or word from streamgetchar getc(3) get character or word from streamgets gets(3) get a string from a streamgetw getc(3) get character or word from streamprintf printf(3) formatted output conversionputc putc(3) put character or word on a streamputchar putc(3) put character or word on a streamputs puts(3) put a string on a streamputw putc(3) put character or word on a streamrewind fseek(3) reposition a streamscanf scanf(3) formatted input conversionsetbuf setbuf(3) assign buffering to a streamsetvbuf setbuf(3) assign buffering to a streamsnprintf printf(3) formatted output conversionsprintf printf(3) formatted output conversionsscanf scanf(3) formatted input conversionungetc ungetc(3) push character back into input streamvfprintf printf(3) formatted output conversionvfscanf scanf(3) formatted input conversionvprintf printf(3) formatted output conversionvscanf scanf(3) formatted input conversionvsnprintf printf(3) formatted output conversionvsprintf printf(3) formatted output conversionvsscanf scanf(3) formatted input conversion.fi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -