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