BSD 4_2 development
[unix-history] / usr / man / man3 / getc.3s
CommitLineData
4c178695
C
1.TH GETC 3S "19 January 1983"
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.IR Getchar ()
32is identical to
33.IR getc ( stdin ) .
34.PP
35.I Fgetc
36behaves like
37.IR 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 (in a 32-bit integer on a VAX-11) 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 (3S)
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(3S),
59putc(3S),
60gets(3S),
61scanf(3S),
62fread(3S),
63ungetc(3S)
64.SH DIAGNOSTICS
65These functions return the integer constant
66.SM
67.B EOF
68at end of file or upon read error.
69.PP
70A stop with message,
71`Reading bad file', means an attempt has been made to
72read from a stream that has not been opened for
73reading by
74.IR fopen .
75.SH BUGS
76The end-of-file return from
77.I getchar
78is incompatible with that in UNIX editions 1-6.
79.PP
80Because it is implemented as a macro,
81.I getc
82treats a
83.I stream
84argument with side effects incorrectly.
85In particular,
86`getc(*f++);'
87doesn't work sensibly.