]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/stdio.3
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man3 / stdio.3
CommitLineData
fea681da
MK
1.\" Copyright (c) 1990, 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
47009d5e 4.\" SPDX-License-Identifier: BSD-4-Clause-UC
fea681da
MK
5.\"
6.\" @(#)stdio.3 6.5 (Berkeley) 5/6/91
7.\"
8.\" Converted for Linux, Mon Nov 29 16:07:22 1993, faith@cs.unc.edu
9.\" Modified, 2001-12-26, aeb
10.\"
45186a5d 11.TH STDIO 3 2021-03-22 "Linux man-pages (unreleased)"
fea681da
MK
12.SH NAME
13stdio \- standard input/output library functions
77e337de
AC
14.SH LIBRARY
15Standard C library
8fc3b2cf 16.RI ( libc ", " \-lc )
fea681da 17.SH SYNOPSIS
c7db92b9 18.nf
fea681da 19.B #include <stdio.h>
68e4db0a 20.PP
c8ce4bc6 21.BI "FILE *" stdin ;
d9cf37f4 22.BI "FILE *" stdout ;
d9cf37f4 23.BI "FILE *" stderr ;
c7db92b9 24.fi
fea681da
MK
25.SH DESCRIPTION
26The standard I/O library provides a simple and efficient buffered stream
c13182ef
MK
27I/O interface.
28Input and output is mapped into logical data streams and the
29physical I/O characteristics are concealed.
30The functions and macros are
fea681da
MK
31listed below; more information is available from the individual man pages.
32.PP
33A stream is associated with an external file (which may be a physical
34device) by
35.I opening
c13182ef
MK
36a file, which may involve creating a new file.
37Creating an existing file
38causes its former contents to be discarded.
39If a file can support positioning requests (such as a disk file,
4af20010 40as opposed to a terminal), then a
fea681da
MK
41.I file position indicator
42associated with the stream is positioned at the start of the file (byte
c13182ef
MK
43zero), unless the file is opened with append mode.
44If append mode is used,
fea681da 45it is unspecified whether the position indicator will be placed at the
c13182ef
MK
46start or the end of the file.
47The position indicator is maintained by
735334d4 48subsequent reads, writes, and positioning requests.
c13182ef 49All input occurs as if the characters were read by successive calls to the
fea681da
MK
50.BR fgetc (3)
51function; all output takes place as if all characters were written by
52successive calls to the
53.BR fputc (3)
54function.
55.PP
56A file is disassociated from a stream by
57.I closing
c13182ef
MK
58the file.
59Output streams are flushed (any unwritten buffer contents are
fea681da 60transferred to the host environment) before the stream is disassociated from
c13182ef
MK
61the file.
62The value of a pointer to a
097585ed 63.I FILE
fea681da
MK
64object is indeterminate after a file is closed (garbage).
65.PP
66A file may be subsequently reopened, by the same or another program
67execution, and its contents reclaimed or modified (if it can be
c13182ef
MK
68repositioned at the start).
69If the main function returns to its original
fea681da
MK
70caller, or the
71.BR exit (3)
72function is called, all open files are closed (hence all output streams are
c13182ef
MK
73flushed) before program termination.
74Other methods of program termination,
fea681da
MK
75such as
76.BR abort (3)
77do not bother about closing files properly.
78.PP
79At program startup, three text streams are predefined and need not be
a43aff68 80opened explicitly:
c13182ef 81.I standard input
a43aff68 82(for reading conventional input),
c13182ef 83.I standard output
f5b9f413 84(for writing conventional output), and
fea681da 85.I standard error
c13182ef
MK
86(for writing diagnostic output).
87These streams are abbreviated
6da3279c
SL
88.IR stdin ,
89.IR stdout ,
fea681da
MK
90and
91.IR stderr .
92When opened, the standard error stream is not fully buffered; the standard
93input and output streams are fully buffered if and only if the streams do
29abb77b 94not refer to an interactive device.
fea681da
MK
95.PP
96Output streams that refer to terminal devices are always line buffered by
97default; pending output to such streams is written automatically whenever
c13182ef
MK
98an input stream that refers to a terminal device is read.
99In cases where a
fea681da
MK
100large amount of computation is done after printing part of a line on an
101output terminal, it is necessary to
102.BR fflush (3)
103the standard output before going off and computing so that the output will
104appear.
105.PP
106The
f19a0f03 107.I stdio
fea681da
MK
108library is a part of the library
109.B libc
5f70d096
MK
110and routines are automatically loaded as needed by
111.BR cc (1).
fea681da 112The
3d341b33 113SYNOPSIS
fea681da
MK
114sections of the following manual pages indicate which include files are to
115be used, what the compiler declaration for the function looks like and
116which external variables are of interest.
117.PP
3b777aff 118The following are defined as macros; these names may not be reused without
fea681da
MK
119first removing their current definitions with
120.BR #undef :
121.BR BUFSIZ ,
122.BR EOF ,
123.BR FILENAME_MAX ,
124.BR FOPEN_MAX ,
125.BR L_cuserid ,
126.BR L_ctermid ,
a5e0a0e4 127.BR L_tmpnam ,
fea681da
MK
128.BR NULL ,
129.BR SEEK_END ,
130.BR SEEK_SET ,
24a7082a 131.BR SEEK_CUR ,
fea681da
MK
132.BR TMP_MAX ,
133.BR clearerr ,
134.BR feof ,
135.BR ferror ,
136.BR fileno ,
834fec09
MK
137.\" Not on Linux: .BR fropen ,
138.\" Not on Linux: .BR fwopen ,
fea681da
MK
139.BR getc ,
140.BR getchar ,
141.BR putc ,
142.BR putchar ,
143.BR stderr ,
144.BR stdin ,
145.BR stdout .
146Function versions of the macro functions
147.BR feof ,
148.BR ferror ,
149.BR clearerr ,
150.BR fileno ,
151.BR getc ,
152.BR getchar ,
153.BR putc ,
154and
155.B putchar
156exist and will be used if the macros definitions are explicitly removed.
73d8cece 157.SS List of functions
0b174fe0
MK
158.nh
159.ad l
9771e6de
MK
160.TS
161;
0b174fe0 162lb lbx
3242546c 163l l.
9771e6de
MK
164Function Description
165_
0b174fe0
MK
166\fBclearerr\fP(3) T{
167check and reset stream status
168T}
169\fBfclose\fP(3) T{
170close a stream
171T}
172\fBfdopen\fP(3) T{
173stream open functions
174T}
175\fBfeof\fP(3) T{
176check and reset stream status
177T}
178\fBferror\fP(3) T{
179check and reset stream status
180T}
181\fBfflush\fP(3) T{
182flush a stream
183T}
184\fBfgetc\fP(3) T{
185get next character or word from input stream
186T}
187\fBfgetpos\fP(3) T{
188reposition a stream
189T}
190\fBfgets\fP(3) T{
191get a line from a stream
192T}
193\fBfileno\fP(3) T{
194return the integer descriptor of the argument stream
195T}
196\fBfopen\fP(3) T{
197stream open functions
198T}
199\fBfprintf\fP(3) T{
200formatted output conversion
201T}
202\fBfpurge\fP(3) T{
203flush a stream
204T}
205\fBfputc\fP(3) T{
206output a character or word to a stream
207T}
208\fBfputs\fP(3) T{
209output a line to a stream
210T}
211\fBfread\fP(3) T{
212binary stream input/output
213T}
214\fBfreopen\fP(3) T{
215stream open functions
216T}
217\fBfscanf\fP(3) T{
218input format conversion
219T}
220\fBfseek\fP(3) T{
221reposition a stream
222T}
223\fBfsetpos\fP(3) T{
224reposition a stream
225T}
226\fBftell\fP(3) T{
227reposition a stream
228T}
229\fBfwrite\fP(3) T{
230binary stream input/output
231T}
232\fBgetc\fP(3) T{
233get next character or word from input stream
234T}
235\fBgetchar\fP(3) T{
236get next character or word from input stream
237T}
238\fBgets\fP(3) T{
239get a line from a stream
240T}
241\fBgetw\fP(3) T{
242get next character or word from input stream
243T}
244\fBmktemp\fP(3) T{
245make temporary filename (unique)
246T}
247\fBperror\fP(3) T{
248system error messages
249T}
250\fBprintf\fP(3) T{
251formatted output conversion
252T}
253\fBputc\fP(3) T{
254output a character or word to a stream
255T}
256\fBputchar\fP(3) T{
257output a character or word to a stream
258T}
259\fBputs\fP(3) T{
260output a line to a stream
261T}
262\fBputw\fP(3) T{
263output a character or word to a stream
264T}
265\fBremove\fP(3) T{
266remove directory entry
267T}
268\fBrewind\fP(3) T{
269reposition a stream
270T}
271\fBscanf\fP(3) T{
272input format conversion
273T}
274\fBsetbuf\fP(3) T{
275stream buffering operations
276T}
277\fBsetbuffer\fP(3) T{
278stream buffering operations
279T}
280\fBsetlinebuf\fP(3) T{
281stream buffering operations
282T}
283\fBsetvbuf\fP(3) T{
284stream buffering operations
285T}
286\fBsprintf\fP(3) T{
287formatted output conversion
288T}
289\fBsscanf\fP(3) T{
290input format conversion
291T}
292\fBstrerror\fP(3) T{
293system error messages
294T}
295\fBsys_errlist\fP(3) T{
296system error messages
297T}
298\fBsys_nerr\fP(3) T{
299system error messages
300T}
301\fBtempnam\fP(3) T{
302temporary file routines
303T}
304\fBtmpfile\fP(3) T{
305temporary file routines
306T}
307\fBtmpnam\fP(3) T{
308temporary file routines
309T}
310\fBungetc\fP(3) T{
311un-get character from input stream
312T}
313\fBvfprintf\fP(3) T{
314formatted output conversion
315T}
316\fBvfscanf\fP(3) T{
317input format conversion
318T}
319\fBvprintf\fP(3) T{
320formatted output conversion
321T}
322\fBvscanf\fP(3) T{
323input format conversion
324T}
325\fBvsprintf\fP(3) T{
326formatted output conversion
327T}
328\fBvsscanf\fP(3) T{
329input format conversion
330T}
9771e6de 331.TE
0b174fe0
MK
332.ad
333.hy
3113c7f3 334.SH STANDARDS
fea681da 335The
f19a0f03 336.I stdio
68e1685c 337library conforms to C89.
47297adb 338.SH SEE ALSO
fea681da
MK
339.BR close (2),
340.BR open (2),
341.BR read (2),
342.BR write (2),
a2337ea3
MK
343.BR stdout (3),
344.BR unlocked_stdio (3)