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