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