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
51 Input and output is mapped into logical data streams and the
52 physical I/O characteristics are concealed.
53 The functions and macros are
54 listed below; more information is available from the individual man pages.
56 A stream is associated with an external file (which may be a physical
59 a file, which may involve creating a new file.
60 Creating an existing file
61 causes its former contents to be discarded.
62 If a file can support positioning requests (such as a disk file,
63 as opposed to a terminal) then a
64 .I file position indicator
65 associated with the stream is positioned at the start of the file (byte
66 zero), unless the file is opened with append mode.
67 If append mode is used,
68 it is unspecified whether the position indicator will be placed at the
69 start or the end of the file.
70 The position indicator is maintained by
71 subsequent reads, writes and positioning requests.
72 All input occurs as if the characters were read by successive calls to the
74 function; all output takes place as if all characters were written by
75 successive calls to the
79 A file is disassociated from a stream by
82 Output streams are flushed (any unwritten buffer contents are
83 transferred to the host environment) before the stream is disassociated from
85 The value of a pointer to a
87 object is indeterminate after a file is closed (garbage).
89 A file may be subsequently reopened, by the same or another program
90 execution, and its contents reclaimed or modified (if it can be
91 repositioned at the start).
92 If the main function returns to its original
95 function is called, all open files are closed (hence all output streams are
96 flushed) before program termination.
97 Other methods of program termination,
100 do not bother about closing files properly.
102 At program startup, three text streams are predefined and need not be
103 opened explicitly \(em
105 (for reading conventional input), \(em
107 (for writing conventional input), and
109 (for writing diagnostic output).
110 These streams are abbreviated
114 When opened, the standard error stream is not fully buffered; the standard
115 input and output streams are fully buffered if and only if the streams do
116 not to refer to an interactive device.
118 Output streams that refer to terminal devices are always line buffered by
119 default; pending output to such streams is written automatically whenever
120 an input stream that refers to a terminal device is read.
122 large amount of computation is done after printing part of a line on an
123 output terminal, it is necessary to
125 the standard output before going off and computing so that the output will
130 library is a part of the library
132 and routines are automatically loaded as needed by the compilers
138 sections of the following manual pages indicate which include files are to
139 be used, what the compiler declaration for the function looks like and
140 which external variables are of interest.
142 The following are defined as macros; these names may not be re-used without
143 first removing their current definitions with
161 .\" Not on Linux: .BR fropen ,
162 .\" Not on Linux: .BR fwopen ,
170 Function versions of the macro functions
180 exist and will be used if the macros definitions are explicitly removed.
181 .SS "List of Functions"
187 check and reset stream status
193 stream open functions
196 check and reset stream status
199 check and reset stream status
205 get next character or word from input stream
208 .\" get a line from a stream (BSD only; renamed to fgetln())
214 get a line from a stream
217 return the integer descriptor of the argument stream
220 stream open functions
223 formatted output conversion
229 output a character or word to a stream
232 output a line to a stream
235 binary stream input/output
238 stream open functions
245 input format conversion
257 binary stream input/output
260 get next character or word from input stream
263 get next character or word from input stream
266 get a line from a stream
269 get next character or word from input stream
272 make temporary filename (unique)
275 system error messages
278 formatted output conversion
281 output a character or word to a stream
284 output a character or word to a stream
287 output a line to a stream
290 output a character or word to a stream
293 remove directory entry
299 input format conversion
302 stream buffering operations
305 stream buffering operations
308 stream buffering operations
311 stream buffering operations
314 formatted output conversion
317 input format conversion
320 system error messages
323 system error messages
326 system error messages
329 temporary file routines
332 temporary file routines
335 temporary file routines
338 un-get character from input stream
341 formatted output conversion
344 input format conversion
347 formatted output conversion
350 input format conversion
353 formatted output conversion
356 input format conversion
360 library conforms to C89.
367 .BR unlocked_stdio (3)