1 .\" Copyright (c) 1990, 1991 Regents of the University of California.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)stdio.3 6.5 (Berkeley) 5/6/91
34 .\" Converted for Linux, Mon Nov 29 16:07:22 1993, faith@cs.unc.edu
35 .\" Modified, 2001-12-26, aeb
37 .TH STDIO 3 2001-12-26 "" "Linux Programmer's Manual"
39 stdio \- standard input/output library functions
49 The standard I/O library provides a simple and efficient buffered stream
50 I/O interface. Input and output is mapped into logical data streams and the
51 physical I/O characteristics are concealed. The functions and macros are
52 listed below; more information is available from the individual man pages.
54 A stream is associated with an external file (which may be a physical
57 a file, which may involve creating a new file. Creating an existing file
58 causes its former contents to be discarded. If a file can support
59 positioning requests (such as a disk file, as opposed to a terminal) then a
60 .I file position indicator
61 associated with the stream is positioned at the start of the file (byte
62 zero), unless the file is opened with append mode. If append mode is used,
63 it is unspecified whether the position indicator will be placed at the
64 start or the end of the file. The position indicator is maintained by
65 subsequent reads, writes and positioning requests. All input occurs
66 as if the characters were read by successive calls to the
68 function; all output takes place as if all characters were written by
69 successive calls to the
73 A file is disassociated from a stream by
75 the file. Output streams are flushed (any unwritten buffer contents are
76 transferred to the host environment) before the stream is disassociated from
77 the file. The value of a pointer to a
79 object is indeterminate after a file is closed (garbage).
81 A file may be subsequently reopened, by the same or another program
82 execution, and its contents reclaimed or modified (if it can be
83 repositioned at the start). If the main function returns to its original
86 function is called, all open files are closed (hence all output streams are
87 flushed) before program termination. Other methods of program termination,
90 do not bother about closing files properly.
92 At program startup, three text streams are predefined and need not be
93 opened explicitly \(em
95 (for reading conventional input), \(em
97 (for writing conventional input), and
99 (for writing diagnostic output). These streams are abbreviated
103 When opened, the standard error stream is not fully buffered; the standard
104 input and output streams are fully buffered if and only if the streams do
105 not to refer to an interactive device.
107 Output streams that refer to terminal devices are always line buffered by
108 default; pending output to such streams is written automatically whenever
109 an input stream that refers to a terminal device is read. In cases where a
110 large amount of computation is done after printing part of a line on an
111 output terminal, it is necessary to
113 the standard output before going off and computing so that the output will
118 library is a part of the library
120 and routines are automatically loaded as needed by the compilers
126 sections of the following manual pages indicate which include files are to
127 be used, what the compiler declaration for the function looks like and
128 which external variables are of interest.
130 The following are defined as macros; these names may not be re-used without
131 first removing their current definitions with
149 .\" Not on Linux: .BR fropen ,
150 .\" Not on Linux: .BR fwopen ,
158 Function versions of the macro functions
168 exist and will be used if the macros definitions are explicitly removed.
169 .SH "LIST OF FUNCTIONS"
175 check and reset stream status
181 stream open functions
184 check and reset stream status
187 check and reset stream status
193 get next character or word from input stream
196 .\" get a line from a stream (BSD only; renamed to fgetln())
202 get a line from a stream
205 return the integer descriptor of the argument stream
208 stream open functions
211 formatted output conversion
217 output a character or word to a stream
220 output a line to a stream
223 binary stream input/output
226 stream open functions
233 input format conversion
245 binary stream input/output
248 get next character or word from input stream
251 get next character or word from input stream
254 get a line from a stream
257 get next character or word from input stream
260 make temporary filename (unique)
263 system error messages
266 formatted output conversion
269 output a character or word to a stream
272 output a character or word to a stream
275 output a line to a stream
278 output a character or word to a stream
281 remove directory entry
287 input format conversion
290 stream buffering operations
293 stream buffering operations
296 stream buffering operations
299 stream buffering operations
302 formatted output conversion
305 input format conversion
308 system error messages
311 system error messages
314 system error messages
317 temporary file routines
320 temporary file routines
323 temporary file routines
326 un-get character from input stream
329 formatted output conversion
332 input format conversion
335 formatted output conversion
338 input format conversion
341 formatted output conversion
344 input format conversion
348 library conforms to ANSI X3.159-1989 (``ANSI C'').