Make all bucket and overflow addresses unsigned
[unix-history] / usr / src / lib / libc / stdio / stdio.3
CommitLineData
c9be6cfe 1.\" Copyright (c) 1990 Regents of the University of California.
466c4377
KM
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
1382c0b2 5.\" @(#)stdio.3 6.4 (Berkeley) %G%
466c4377 6.\"
c9be6cfe 7.TH STDIO 3 ""
466c4377
KM
8.UC 4
9.SH NAME
10stdio \- standard buffered input/output package
11.SH SYNOPSIS
12.B #include <stdio.h>
13.PP
14.SM
15.B FILE
16.B *stdin;
17.br
18.SM
19.B FILE
20.B *stdout;
21.br
22.SM
23.B FILE
24.B *stderr;
25.SH DESCRIPTION
c9be6cfe
KB
26The functions described here constitute a user-level buffering scheme.
27The in-line macros
28.IR getc (3)
466c4377 29and
c9be6cfe
KB
30.IR putc (3)
31handle characters quickly.
32The higher level routines in
33.I stdio
466c4377
KM
34all use
35.I getc
36and
8a0524cf 37.IR putc ;
466c4377
KM
38they can be freely intermixed.
39.PP
40A file with associated buffering is called a
8a0524cf 41.IR stream ,
466c4377
KM
42and is declared to be a pointer to a defined type
43.SM
8a0524cf 44.BR FILE .
c9be6cfe
KB
45.IR Fopen (3)
46and
47.IR funopen (3)
48create certain descriptive data for a stream
49and return a pointer to designate the stream in all further transactions.
8a0524cf 50There are three normally open streams with constant pointers declared in
466c4377
KM
51the include file and associated with the standard open files:
52.TP 10n
8a0524cf 53.B stdin
466c4377
KM
54standard input file
55.br
56.ns
57.TP
58.B stdout
59standard output file
60.br
61.ns
62.TP
8a0524cf 63.B stderr
466c4377
KM
64standard error file
65.PP
66A constant `pointer'
67.SM
68.B NULL
69(0)
70designates no stream at all.
71.PP
72An integer constant
73.SM
74.B EOF
8a0524cf 75(\-1) is returned upon end of file or error by integer functions that
466c4377
KM
76deal with streams.
77.PP
78Any routine that uses the standard input/output package
8a0524cf 79must include the header file
c9be6cfe
KB
80.RI < stdio.h > .
81The constants and functions listed here
8a0524cf 82are declared in the include file and need no further declaration.
c9be6cfe
KB
83The following are implemented as macros;
84these names may not be reused
85without first removing their current definitions with
86.BR #undef :
1382c0b2
KB
87BUFSIZ, EOF, FILENAME_MAX, FOPEN_MAX, L_cuserid, L_tmpnam, NULL,
88SEEK_END, SEEK_SET, SEE_CUR, TMP_MAX, clearerr, feof, ferror,
89fileno, fropen, fwopen, getc, getchar, putc, putchar, stderr,
90stdin, stdout.
91Function versions of the macro functions feof, ferror, clearerr, fileno,
92getc, getchar, putc, and putchar exist and will be used if the macros
93definitions are explicitly removed.
c9be6cfe
KB
94.PP
95Output streams that refer to terminal devices
96are always line buffered by default;
97pending output to such streams is written automatically
98whenever an input stream that refers to a terminal device is read.
99In cases where a large amount of computation is done after printing
100part of a line on an output terminal, it is necessary to
101.IR fflush (3)
102the standard output before going off and computing so that the output
103will appear.
466c4377 104.SH "SEE ALSO"
c9be6cfe
KB
105open(2), close(2), read(2), write(2)
106.br
1382c0b2 107all of the manual entries listed below
c9be6cfe 108.SH "RETURN VALUE"
466c4377
KM
109The value
110.SM
111.B EOF
112is returned uniformly to indicate that a
113.SM
114.B FILE
115pointer has not been initialized with
8a0524cf
KM
116.IR fopen ,
117input (output) has been attempted on an output (input) stream, or a
466c4377
KM
118.SM
119.B FILE
120pointer designates corrupt or otherwise unintelligible
121.SM
122.B FILE
123data.
8a0524cf
KM
124.SH BUGS
125The standard buffered functions do not interact well with certain other
126library and system functions, especially \fIvfork\fP and \fIabort\fP.
127.SH "LIST OF FUNCTIONS"
128.sp 2
129.nf
c9be6cfe
KB
130.ta \w'setlinebuf'u+2n +\w'setvbuf.3'u+10n
131\fIName\fP \fIAppears on Page\fP \fIDescription\fP
132.ta \w'setlinebuf'u+4n +\w'setvbuf.3'u+4n
133.sp 5p
134clearerr ferror.3 stream status inquiries
135fclose fclose.3 close a stream
136fdopen fopen.3 open a stream
137feof ferror.3 stream status inquiries
138ferror ferror.3 stream status inquiries
139fflush fflush.3 flush a stream
140fgetc getc.3 get a character or word from a stream
141fgetline fgetline.3 get a line from a stream
142fgetpos fseek.3 reposition a stream
143fgets fgets.3 get a line from a stream
144fileno ferror.3 stream status inquiries
145fmemopen fmemopen.3 open a block of memory as a stream
146fopen fopen.3 open a stream
147fprintf printf.3 formatted output conversion
148fpurge fpurge.3 discard buffered stream data
149fputc putc.3 put a character or word to a stream
150fputs fputs.3 put a line to a stream
151fread fread.3 stream binary input/output
152freopen fopen.3 open a stream
153fscanf scanf.3 formatted input conversion
154fseek fseek.3 reposition a stream
155fsetpos fseek.3 reposition a stream
156ftell fseek.3 reposition a stream
157funopen fopen.3 open a stream
158fwrite fread.3 stream binary input/output
159getc getc.3 get a character or word from a stream
160getchar getc.3 get a character or word from a stream
161gets fgets.3 get a line from a stream
162getw getc.3 get a character or word from a stream
163printf printf.3 formatted output conversion
164putc putc.3 put a character or word to a stream
165putchar putc.3 put a character or word to a stream
166puts fputs.3 put a line to a stream
167putw putc.3 put a character or word to a stream
1382c0b2 168remove remove.3 remove a file
c9be6cfe
KB
169rewind fseek.3 reposition a stream
170scanf scanf.3 formatted input conversion
171setbuf setvbuf.3 assign buffering to a stream
172setbuffer setvbuf.3 assign buffering to a stream
173setlinebuf setvbuf.3 assign buffering to a stream
174setvbuf setvbuf.3 assign buffering to a stream
c9be6cfe
KB
175snprintf printf.3 formatted output conversion
176sprintf printf.3 formatted output conversion
1382c0b2
KB
177tmpfile tmpnam.3 create a temporary stream
178tmpnam tmpnam.3 create a temporary file name
c9be6cfe
KB
179ungetc ungetc.3 push character back into input stream
180vfprintf printf.3 formatted output conversion
181vprintf printf.3 formatted output conversion
c9be6cfe
KB
182vsnprintf printf.3 formatted output conversion
183vsprintf printf.3 formatted output conversion
184.fi