176 lines
10 KiB
HTML
176 lines
10 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>stdio(3)</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<H1>stdio(3)</H1>
|
|
<HR>
|
|
<PRE>
|
|
|
|
</PRE>
|
|
<H2>NAME</H2><PRE>
|
|
stdio - standard buffered input/output package
|
|
|
|
|
|
</PRE>
|
|
<H2>SYNOPSIS</H2><PRE>
|
|
<STRONG>#include</STRONG> <STRONG><stdio.h></STRONG>
|
|
|
|
<STRONG>FILE</STRONG> <STRONG>*stdin;</STRONG>
|
|
<STRONG>FILE</STRONG> <STRONG>*stdout;</STRONG>
|
|
<STRONG>FILE</STRONG> <STRONG>*stderr;</STRONG>
|
|
|
|
|
|
</PRE>
|
|
<H2>DESCRIPTION</H2><PRE>
|
|
The functions in the standard I/O library constitute a user-level
|
|
buffering scheme. The in-line macros <STRONG>getc</STRONG> and <STRONG><A HREF="../man3/putc.3.html">putc(3)</A></STRONG> handle characters
|
|
quickly. The higher level routines <STRONG>gets</STRONG>, <STRONG>fgets</STRONG>, <STRONG>scanf</STRONG>, <STRONG>fscanf</STRONG>, <STRONG>fread</STRONG>,
|
|
<STRONG>puts</STRONG>, <STRONG>fputs</STRONG>, <STRONG>printf</STRONG>, <STRONG>fprintf</STRONG>, <STRONG>fwrite</STRONG> all use <STRONG>getc</STRONG> and <STRONG>putc</STRONG>; they can be
|
|
freely intermixed.
|
|
|
|
A file with associated buffering is called a <EM>stream</EM>, and is declared to
|
|
be a pointer to a defined type <STRONG>FILE</STRONG>. <STRONG><A HREF="../man3/Fopen.3.html">Fopen(3)</A></STRONG> creates certain
|
|
descriptive data for a stream and returns a pointer to designate the
|
|
stream in all further transactions. There are three normally open
|
|
streams with constant pointers declared in the include file and
|
|
associated with the standard open files:
|
|
|
|
<STRONG>stdin</STRONG> standard input file
|
|
<STRONG>stdout</STRONG> standard output file
|
|
<STRONG>stderr</STRONG> standard error file
|
|
|
|
A constant `pointer' <STRONG>NULL</STRONG> (0) designates no stream at all.
|
|
|
|
An integer constant <STRONG>EOF</STRONG> (-1) is returned upon end of file or error by
|
|
integer functions that deal with streams.
|
|
|
|
Any routine that uses the standard input/output package must include the
|
|
header file <<EM>stdio</EM>.<EM>h</EM>> of pertinent macro definitions. The functions and
|
|
constants mentioned in the standard I/O manual pages are declared in the
|
|
include file and need no further declaration. The constants, and the
|
|
following `functions' are implemented as macros; redeclaration of these
|
|
names is perilous: <STRONG>clearerr</STRONG>, <STRONG>getc</STRONG>, <STRONG>getchar</STRONG>, <STRONG>putc</STRONG>, <STRONG>putchar</STRONG>, <STRONG>feof</STRONG>, <STRONG>ferror</STRONG>,
|
|
<STRONG>fileno</STRONG>.
|
|
|
|
|
|
</PRE>
|
|
<H2>SEE ALSO</H2><PRE>
|
|
<STRONG><A HREF="../man2/open.2.html">open(2)</A></STRONG>, <STRONG><A HREF="../man2/close.2.html">close(2)</A></STRONG>, <STRONG><A HREF="../man2/read.2.html">read(2)</A></STRONG>, <STRONG><A HREF="../man2/write.2.html">write(2)</A></STRONG>, <STRONG><A HREF="../man3/fclose.3.html">fclose(3)</A></STRONG>, <STRONG><A HREF="../man3/ferror.3.html">ferror(3)</A></STRONG>, <STRONG><A HREF="../man3/fopen.3.html">fopen(3)</A></STRONG>,
|
|
<STRONG><A HREF="../man3/fread.3.html">fread(3)</A></STRONG>, <STRONG><A HREF="../man3/fseek.3.html">fseek(3)</A></STRONG>, <STRONG><A HREF="../man3/getc.3.html">getc(3)</A></STRONG>, <STRONG><A HREF="../man3/gets.3.html">gets(3)</A></STRONG>, <STRONG><A HREF="../man3/printf.3.html">printf(3)</A></STRONG>, <STRONG><A HREF="../man3/putc.3.html">putc(3)</A></STRONG>, <STRONG><A HREF="../man3/puts.3.html">puts(3)</A></STRONG>,
|
|
<STRONG><A HREF="../man3/scanf.3.html">scanf(3)</A></STRONG>, <STRONG><A HREF="../man3/setbuf.3.html">setbuf(3)</A></STRONG>, <STRONG><A HREF="../man3/ungetc.3.html">ungetc(3)</A></STRONG>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</PRE>
|
|
<H2>DIAGNOSTICS</H2><PRE>
|
|
The value <STRONG>EOF</STRONG> is returned uniformly to indicate that a <STRONG>FILE</STRONG> pointer has
|
|
not been initialized with <STRONG>fopen</STRONG>, input (output) has been attempted on an
|
|
output (input) stream, or a <STRONG>FILE</STRONG> pointer designates corrupt or otherwise
|
|
unintelligible <STRONG>FILE</STRONG> data.
|
|
|
|
For purposes of efficiency, this implementation of the standard library
|
|
has been changed to line buffer output to a terminal by default and
|
|
attempts to do this transparently by flushing the output whenever a
|
|
<STRONG><A HREF="../man2/read.2.html">read(2)</A></STRONG> from the standard input is necessary. This is almost always
|
|
transparent, but may cause confusion or malfunctioning of programs which
|
|
use standard i/o routines but use <STRONG><A HREF="../man2/read.2.html">read(2)</A></STRONG> themselves to read from the
|
|
standard input.
|
|
|
|
In cases where a large amount of computation is done after printing part
|
|
of a line on an output terminal, it is necessary to <STRONG><A HREF="../man3/fflush.3.html">fflush(3)</A></STRONG> the
|
|
standard output before going off and computing so that the output will
|
|
appear.
|
|
|
|
|
|
</PRE>
|
|
<H2>BUGS</H2><PRE>
|
|
The standard buffered functions do not interact well with certain other
|
|
library and system functions, especially <STRONG>fork</STRONG> and <STRONG>abort</STRONG>.
|
|
|
|
|
|
</PRE>
|
|
<H2>LIST OF FUNCTIONS</H2><PRE>
|
|
|
|
|
|
<STRONG>Name</STRONG> <STRONG>Appears</STRONG> <STRONG>on</STRONG> <STRONG>Page</STRONG> <STRONG>Description</STRONG>
|
|
|
|
clearerr <STRONG><A HREF="../man3/ferror.3.html">ferror(3)</A></STRONG> stream status inquiries
|
|
fclose <STRONG><A HREF="../man3/fclose.3.html">fclose(3)</A></STRONG> close or flush a stream
|
|
fdopen <STRONG><A HREF="../man3/fopen.3.html">fopen(3)</A></STRONG> open a stream
|
|
feof <STRONG><A HREF="../man3/ferror.3.html">ferror(3)</A></STRONG> stream status inquiries
|
|
ferror <STRONG><A HREF="../man3/ferror.3.html">ferror(3)</A></STRONG> stream status inquiries
|
|
fflush <STRONG><A HREF="../man3/fclose.3.html">fclose(3)</A></STRONG> close or flush a stream
|
|
fgetc <STRONG><A HREF="../man3/getc.3.html">getc(3)</A></STRONG> get character or word from stream
|
|
fgets <STRONG><A HREF="../man3/gets.3.html">gets(3)</A></STRONG> get a string from a stream
|
|
fileno <STRONG><A HREF="../man3/ferror.3.html">ferror(3)</A></STRONG> stream status inquiries
|
|
fopen <STRONG><A HREF="../man3/fopen.3.html">fopen(3)</A></STRONG> open a stream
|
|
fprintf <STRONG><A HREF="../man3/printf.3.html">printf(3)</A></STRONG> formatted output conversion
|
|
fputc <STRONG><A HREF="../man3/putc.3.html">putc(3)</A></STRONG> put character or word on a stream
|
|
fputs <STRONG><A HREF="../man3/puts.3.html">puts(3)</A></STRONG> put a string on a stream
|
|
fread <STRONG><A HREF="../man3/fread.3.html">fread(3)</A></STRONG> buffered binary input/output
|
|
freopen <STRONG><A HREF="../man3/fopen.3.html">fopen(3)</A></STRONG> open a stream
|
|
fscanf <STRONG><A HREF="../man3/scanf.3.html">scanf(3)</A></STRONG> formatted input conversion
|
|
fseek <STRONG><A HREF="../man3/fseek.3.html">fseek(3)</A></STRONG> reposition a stream
|
|
ftell <STRONG><A HREF="../man3/fseek.3.html">fseek(3)</A></STRONG> reposition a stream
|
|
fwrite <STRONG><A HREF="../man3/fread.3.html">fread(3)</A></STRONG> buffered binary input/output
|
|
getc <STRONG><A HREF="../man3/getc.3.html">getc(3)</A></STRONG> get character or word from stream
|
|
getchar <STRONG><A HREF="../man3/getc.3.html">getc(3)</A></STRONG> get character or word from stream
|
|
gets <STRONG><A HREF="../man3/gets.3.html">gets(3)</A></STRONG> get a string from a stream
|
|
getw <STRONG><A HREF="../man3/getc.3.html">getc(3)</A></STRONG> get character or word from stream
|
|
printf <STRONG><A HREF="../man3/printf.3.html">printf(3)</A></STRONG> formatted output conversion
|
|
putc <STRONG><A HREF="../man3/putc.3.html">putc(3)</A></STRONG> put character or word on a stream
|
|
putchar <STRONG><A HREF="../man3/putc.3.html">putc(3)</A></STRONG> put character or word on a stream
|
|
puts <STRONG><A HREF="../man3/puts.3.html">puts(3)</A></STRONG> put a string on a stream
|
|
putw <STRONG><A HREF="../man3/putc.3.html">putc(3)</A></STRONG> put character or word on a stream
|
|
rewind <STRONG><A HREF="../man3/fseek.3.html">fseek(3)</A></STRONG> reposition a stream
|
|
scanf <STRONG><A HREF="../man3/scanf.3.html">scanf(3)</A></STRONG> formatted input conversion
|
|
setbuf <STRONG><A HREF="../man3/setbuf.3.html">setbuf(3)</A></STRONG> assign buffering to a stream
|
|
setvbuf <STRONG><A HREF="../man3/setbuf.3.html">setbuf(3)</A></STRONG> assign buffering to a stream
|
|
snprintf <STRONG><A HREF="../man3/printf.3.html">printf(3)</A></STRONG> formatted output conversion
|
|
sprintf <STRONG><A HREF="../man3/printf.3.html">printf(3)</A></STRONG> formatted output conversion
|
|
sscanf <STRONG><A HREF="../man3/scanf.3.html">scanf(3)</A></STRONG> formatted input conversion
|
|
ungetc <STRONG><A HREF="../man3/ungetc.3.html">ungetc(3)</A></STRONG> push character back into input stream
|
|
vfprintf <STRONG><A HREF="../man3/printf.3.html">printf(3)</A></STRONG> formatted output conversion
|
|
vfscanf <STRONG><A HREF="../man3/scanf.3.html">scanf(3)</A></STRONG> formatted input conversion
|
|
vprintf <STRONG><A HREF="../man3/printf.3.html">printf(3)</A></STRONG> formatted output conversion
|
|
vscanf <STRONG><A HREF="../man3/scanf.3.html">scanf(3)</A></STRONG> formatted input conversion
|
|
vsnprintf <STRONG><A HREF="../man3/printf.3.html">printf(3)</A></STRONG> formatted output conversion
|
|
vsprintf <STRONG><A HREF="../man3/printf.3.html">printf(3)</A></STRONG> formatted output conversion
|
|
vsscanf <STRONG><A HREF="../man3/scanf.3.html">scanf(3)</A></STRONG> formatted input conversion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</PRE>
|
|
</BODY>
|
|
</HTML>
|