source: trunk/minix/man/man3/stdio.3@ 20

Last change on this file since 20 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 5.3 KB
RevLine 
[9]1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)stdio.3s 6.2 (Berkeley) 5/13/86
6.\"
7.TH STDIO 3 "May 13, 1986"
8.UC 4
9.SH NAME
10stdio \- standard buffered input/output package
11.SH SYNOPSIS
12.nf
13.ft B
14#include <stdio.h>
15
16FILE *stdin;
17FILE *stdout;
18FILE *stderr;
19.ft R
20.fi
21.SH DESCRIPTION
22The functions in the standard I/O library constitute a user-level buffering
23scheme. The in-line macros
24.B getc
25and
26.BR putc (3)
27handle characters quickly. The higher level routines
28.BR gets ,
29.BR fgets ,
30.BR scanf ,
31.BR fscanf ,
32.BR fread ,
33.BR puts ,
34.BR fputs ,
35.BR printf ,
36.BR fprintf ,
37.BR fwrite
38all use
39.B getc
40and
41.BR putc ;
42they can be freely intermixed.
43.PP
44A file with associated buffering is called a
45.IR stream ,
46and is declared to be a pointer to a defined type
47.SM
48.BR FILE .
49.BR Fopen (3)
50creates certain descriptive data for a stream
51and returns a pointer to designate the stream in all further transactions.
52There are three normally open streams with constant pointers declared in
53the include file and associated with the standard open files:
54.TP 10n
55.B stdin
56standard input file
57.br
58.ns
59.TP
60.B stdout
61standard output file
62.br
63.ns
64.TP
65.B stderr
66standard error file
67.PP
68A constant `pointer'
69.SM
70.B NULL
71(0)
72designates no stream at all.
73.PP
74An integer constant
75.SM
76.B EOF
77(\-1) is returned upon end of file or error by integer functions that
78deal with streams.
79.PP
80Any routine that uses the standard input/output package
81must include the header file
82.RI < stdio.h >
83of pertinent macro definitions.
84The functions and constants mentioned in the standard I/O manual pages
85are declared in the include file and need no further declaration.
86The constants, and the following `functions' are
87implemented as macros; redeclaration of these names is perilous:
88.BR clearerr ,
89.BR getc ,
90.BR getchar ,
91.BR putc ,
92.BR putchar ,
93.BR feof ,
94.BR ferror ,
95.BR fileno .
96.SH "SEE ALSO"
97.BR open (2),
98.BR close (2),
99.BR read (2),
100.BR write (2),
101.BR fclose (3),
102.BR ferror (3),
103.BR fopen (3),
104.BR fread (3),
105.BR fseek (3),
106.BR getc (3),
107.BR gets (3),
108.BR printf (3),
109.BR putc (3),
110.BR puts (3),
111.BR scanf (3),
112.BR setbuf (3),
113.BR ungetc (3).
114.SH DIAGNOSTICS
115The value
116.SM
117.B EOF
118is returned uniformly to indicate that a
119.SM
120.B FILE
121pointer has not been initialized with
122.BR fopen ,
123input (output) has been attempted on an output (input) stream, or a
124.SM
125.B FILE
126pointer designates corrupt or otherwise unintelligible
127.SM
128.B FILE
129data.
130.PP
131For purposes of efficiency, this implementation of the standard library
132has been changed to line buffer output to a terminal by default and attempts
133to do this transparently by flushing the output whenever a
134.BR read (2)
135from the standard input is necessary. This is almost always transparent,
136but may cause confusion or malfunctioning of programs which use
137standard i/o routines but use
138.BR read (2)
139themselves to read from the standard input.
140.PP
141In cases where a large amount of computation is done after printing
142part of a line on an output terminal, it is necessary to
143.BR fflush (3)
144the standard output before going off and computing so that the output
145will appear.
146.SH BUGS
147The standard buffered functions do not interact well with certain other
148library and system functions, especially \fBfork\fP and \fBabort\fP.
149.SH "LIST OF FUNCTIONS"
150.sp 2
151.nf
152.ta \w'setlinebuf'u+2n +\w'setbuf(3)'u+10n
153\fBName\fP \fBAppears on Page\fP \fBDescription\fP
154.ta \w'setlinebuf'u+4n +\w'setbuf(3)'u+4n
155.sp 5p
156clearerr ferror(3) stream status inquiries
157fclose fclose(3) close or flush a stream
158fdopen fopen(3) open a stream
159feof ferror(3) stream status inquiries
160ferror ferror(3) stream status inquiries
161fflush fclose(3) close or flush a stream
162fgetc getc(3) get character or word from stream
163fgets gets(3) get a string from a stream
164fileno ferror(3) stream status inquiries
165fopen fopen(3) open a stream
166fprintf printf(3) formatted output conversion
167fputc putc(3) put character or word on a stream
168fputs puts(3) put a string on a stream
169fread fread(3) buffered binary input/output
170freopen fopen(3) open a stream
171fscanf scanf(3) formatted input conversion
172fseek fseek(3) reposition a stream
173ftell fseek(3) reposition a stream
174fwrite fread(3) buffered binary input/output
175getc getc(3) get character or word from stream
176getchar getc(3) get character or word from stream
177gets gets(3) get a string from a stream
178getw getc(3) get character or word from stream
179printf printf(3) formatted output conversion
180putc putc(3) put character or word on a stream
181putchar putc(3) put character or word on a stream
182puts puts(3) put a string on a stream
183putw putc(3) put character or word on a stream
184rewind fseek(3) reposition a stream
185scanf scanf(3) formatted input conversion
186setbuf setbuf(3) assign buffering to a stream
187setvbuf setbuf(3) assign buffering to a stream
188snprintf printf(3) formatted output conversion
189sprintf printf(3) formatted output conversion
190sscanf scanf(3) formatted input conversion
191ungetc ungetc(3) push character back into input stream
192vfprintf printf(3) formatted output conversion
193vfscanf scanf(3) formatted input conversion
194vprintf printf(3) formatted output conversion
195vscanf scanf(3) formatted input conversion
196vsnprintf printf(3) formatted output conversion
197vsprintf printf(3) formatted output conversion
198vsscanf scanf(3) formatted input conversion
199.fi
Note: See TracBrowser for help on using the repository browser.