Bell 32V release
[unix-history] / usr / man / man3 / stdio.3s
CommitLineData
c4665c80
TL
1.TH STDIO 3S
2.SH NAME
3stdio \- standard buffered input/output package
4.SH SYNOPSIS
5.B #include <stdio.h>
6.PP
7.SM
8.B FILE
9.B *stdin;
10.br
11.SM
12.B FILE
13.B *stdout;
14.br
15.SM
16.B FILE
17.B *stderr;
18.SH DESCRIPTION
19The functions described in Sections 3S constitute an efficient
20user-level buffering scheme.
21The in-line macros
22.I getc
23and
24.IR putc (3)
25handle characters quickly.
26The higher level routines
27.I "gets, fgets, scanf, fscanf, fread,"
28.I "puts, fputs, printf, fprintf, fwrite"
29all use
30.I getc
31and
32.I putc;
33they can be freely intermixed.
34.PP
35A file with associated buffering is called a
36.I stream,
37and is declared to be a pointer to a defined type
38.SM
39.B FILE.
40.IR Fopen (3)
41creates certain descriptive data for a stream
42and returns a pointer to designate the stream in all
43further transactions.
44There are three normally open streams with constant
45pointers declared in
46the include file and associated with the standard open files:
47.TP 10n
48.BR stdin
49standard input file
50.br
51.ns
52.TP
53.B stdout
54standard output file
55.br
56.ns
57.TP
58.BR stderr
59standard error file
60.PP
61A constant `pointer'
62.SM
63.B NULL
64(0)
65designates no stream at all.
66.PP
67An integer constant
68.SM
69.B EOF
70(\-1) is returned
71upon end of file or error by integer functions that
72deal with streams.
73.PP
74Any routine that uses the standard input/output package
75must include the header file <stdio.h> of pertinent
76macro definitions.
77The functions and constants mentioned in sections labeled 3S
78are declared in the include file
79and need no further declaration.
80The constants, and the following `functions' are
81implemented as macros; redeclaration of these names
82is perilous:
83.I getc,
84.I getchar,
85.I putc,
86.I putchar,
87.I feof,
88.I ferror,
89.IR fileno .
90.SH "SEE ALSO"
91open(2), close(2), read(2), write(2)
92.SH DIAGNOSTICS
93The value
94.SM
95.B EOF
96is returned uniformly to indicate that a
97.SM
98.B FILE
99pointer has not been initialized with
100.I fopen,
101input (output) has been attempted on an output (input) stream,
102or a
103.SM
104.B FILE
105pointer designates corrupt or otherwise unintelligible
106.SM
107.B FILE
108data.