BSD 2 development
[unix-history] / man / getc.u
CommitLineData
8c95d292
BJ
1.TH GETC UCB 4/8/79
2.SH NAME
3getc, getchar, fgetc, getw \- get character or word from stream
4.SH SYNOPSIS
5.B #include <nstdio.h>
6.PP
7.B int getc(stream)
8.br
9.SM
10.B FILE
11.B *stream;
12.PP
13.B int getchar()
14.PP
15.B int peekc(stream)
16.br
17.SM
18.B FILE
19.B *stream;
20.PP
21.B int peekchar()
22.PP
23.B int fgetc(stream)
24.br
25.SM
26.B FILE
27.B *stream;
28.PP
29.B int getw(stream)
30.br
31.SM
32.B FILE
33.B *stream;
34.SH DESCRIPTION
35.I Getc
36returns the next character from the named input
37.IR stream .
38.PP
39.I Getchar()
40is identical to
41.IR getc(stdin) .
42.PP
43.I Peekc
44returns the next character from the named input, without advancing the pointer.
45Note that it may cause the buffer to be filled and is inadvisable for pipes.
46.PP
47.I Peekchar()
48is identical to
49.IR peekc(stdin) .
50.PP
51.I Fgetc
52behaves like
53.I getc,
54but is a genuine function, not a macro;
55it may be used to save object text.
56.PP
57.I Getw
58returns the next
59word (32-bit integer on a VAX-11) from the named input
60.IR stream .
61It returns the constant
62.SM
63.B EOF
64upon end of file or error, but since that is a good
65integer value,
66.I feof
67and
68.IR ferror (3)
69should be used to check the success of
70.IR getw .
71.I Getw
72assumes no special alignment in the file.
73.SH "SEE ALSO"
74fopen(3), putc(3),
75gets(3), scanf(3),
76fread(3),
77ungetc(3)
78.SH DIAGNOSTICS
79These functions return the integer constant
80.SM
81.B EOF
82at end of file or upon read error.
83.PP
84A stop with message,
85`Reading bad file', means an attempt has been made to
86read from a stream that has not been opened for
87reading by
88.IR fopen .
89.SH AUTHOR
90Peekc was a product of the laboratory for computer science, M.I.T.
91.SH BUGS
92The end-of-file return from
93.I getchar
94is incompatible with that in UNIX editions 1-6.
95.PP
96Because it is implemented as a macro,
97.I getc
98treats a
99.I stream
100argument with side effects incorrectly.
101In particular,
102`getc(*f++);'
103doesn't work sensibly.