1 .\" Copyright (c) 1990, 1991 Regents of the University of California.
2 .\" All rights reserved.
4 .\" SPDX-License-Identifier: BSD-4-Clause-UC
6 .\" @(#)stdio.3 6.5 (Berkeley) 5/6/91
8 .\" Converted for Linux, Mon Nov 29 16:07:22 1993, faith@cs.unc.edu
9 .\" Modified, 2001-12-26, aeb
11 .TH STDIO 3 2021-03-22 GNU "Linux Programmer's Manual"
13 stdio \- standard input/output library functions
16 .RI ( libc ", " \-lc )
26 The standard I/O library provides a simple and efficient buffered stream
28 Input and output is mapped into logical data streams and the
29 physical I/O characteristics are concealed.
30 The functions and macros are
31 listed below; more information is available from the individual man pages.
33 A stream is associated with an external file (which may be a physical
36 a file, which may involve creating a new file.
37 Creating an existing file
38 causes its former contents to be discarded.
39 If a file can support positioning requests (such as a disk file,
40 as opposed to a terminal), then a
41 .I file position indicator
42 associated with the stream is positioned at the start of the file (byte
43 zero), unless the file is opened with append mode.
44 If append mode is used,
45 it is unspecified whether the position indicator will be placed at the
46 start or the end of the file.
47 The position indicator is maintained by
48 subsequent reads, writes, and positioning requests.
49 All input occurs as if the characters were read by successive calls to the
51 function; all output takes place as if all characters were written by
52 successive calls to the
56 A file is disassociated from a stream by
59 Output streams are flushed (any unwritten buffer contents are
60 transferred to the host environment) before the stream is disassociated from
62 The value of a pointer to a
64 object is indeterminate after a file is closed (garbage).
66 A file may be subsequently reopened, by the same or another program
67 execution, and its contents reclaimed or modified (if it can be
68 repositioned at the start).
69 If the main function returns to its original
72 function is called, all open files are closed (hence all output streams are
73 flushed) before program termination.
74 Other methods of program termination,
77 do not bother about closing files properly.
79 At program startup, three text streams are predefined and need not be
82 (for reading conventional input),
84 (for writing conventional output), and
86 (for writing diagnostic output).
87 These streams are abbreviated
92 When opened, the standard error stream is not fully buffered; the standard
93 input and output streams are fully buffered if and only if the streams do
94 not refer to an interactive device.
96 Output streams that refer to terminal devices are always line buffered by
97 default; pending output to such streams is written automatically whenever
98 an input stream that refers to a terminal device is read.
100 large amount of computation is done after printing part of a line on an
101 output terminal, it is necessary to
103 the standard output before going off and computing so that the output will
108 library is a part of the library
110 and routines are automatically loaded as needed by
114 sections of the following manual pages indicate which include files are to
115 be used, what the compiler declaration for the function looks like and
116 which external variables are of interest.
118 The following are defined as macros; these names may not be reused without
119 first removing their current definitions with
137 .\" Not on Linux: .BR fropen ,
138 .\" Not on Linux: .BR fwopen ,
146 Function versions of the macro functions
156 exist and will be used if the macros definitions are explicitly removed.
157 .SS List of functions
167 check and reset stream status
173 stream open functions
176 check and reset stream status
179 check and reset stream status
185 get next character or word from input stream
191 get a line from a stream
194 return the integer descriptor of the argument stream
197 stream open functions
200 formatted output conversion
206 output a character or word to a stream
209 output a line to a stream
212 binary stream input/output
215 stream open functions
218 input format conversion
230 binary stream input/output
233 get next character or word from input stream
236 get next character or word from input stream
239 get a line from a stream
242 get next character or word from input stream
245 make temporary filename (unique)
248 system error messages
251 formatted output conversion
254 output a character or word to a stream
257 output a character or word to a stream
260 output a line to a stream
263 output a character or word to a stream
266 remove directory entry
272 input format conversion
275 stream buffering operations
277 \fBsetbuffer\fP(3) T{
278 stream buffering operations
280 \fBsetlinebuf\fP(3) T{
281 stream buffering operations
284 stream buffering operations
287 formatted output conversion
290 input format conversion
293 system error messages
295 \fBsys_errlist\fP(3) T{
296 system error messages
299 system error messages
302 temporary file routines
305 temporary file routines
308 temporary file routines
311 un-get character from input stream
314 formatted output conversion
317 input format conversion
320 formatted output conversion
323 input format conversion
326 formatted output conversion
329 input format conversion
337 library conforms to C89.
344 .BR unlocked_stdio (3)