document sticky EOF
[unix-history] / usr / src / lib / libc / stdio / getc.3
CommitLineData
c8869633 1.\" @(#)getc.3 6.2 (Berkeley) %G%
e3c5dfdb 2.\"
898d0dd0 3.TH GETC 3S ""
e3c5dfdb
KM
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
596d2e3d 34.IR Getchar ()
e3c5dfdb 35is identical to
596d2e3d 36.IR getc ( stdin ) .
e3c5dfdb
KM
37.PP
38.I Fgetc
39behaves like
596d2e3d 40.IR getc ,
e3c5dfdb
KM
41but is a genuine function, not a macro;
42it may be used to save object text.
43.PP
44.I Getw
45returns the next
12e29951
MK
46.B int
47(a 32-bit integer on a VAX-11) from the named input
e3c5dfdb
KM
48.IR stream .
49It returns the constant
50.SM
51.B EOF
52upon end of file or error, but since that is a good
53integer value,
54.I feof
55and
596d2e3d 56.IR ferror (3S)
e3c5dfdb
KM
57should be used to check the success of
58.IR getw .
59.I Getw
60assumes no special alignment in the file.
61.SH "SEE ALSO"
12e29951 62clearerr(3S),
596d2e3d
KM
63fopen(3S),
64putc(3S),
65gets(3S),
66scanf(3S),
67fread(3S),
68ungetc(3S)
e3c5dfdb
KM
69.SH DIAGNOSTICS
70These functions return the integer constant
71.SM
72.B EOF
12e29951
MK
73at end of file, upon read error,
74or if an attempt is made to read a file not opened by
e3c5dfdb 75.IR fopen .
12e29951
MK
76The end-of-file condition is remembered,
77even on a terminal,
78and all subsequent attempts to read will return
79.B EOF
80until the condition is cleared with
81.IR clearerr (3S).
e3c5dfdb 82.SH BUGS
e3c5dfdb
KM
83Because it is implemented as a macro,
84.I getc
85treats a
86.I stream
87argument with side effects incorrectly.
88In particular,
89`getc(*f++);'
90doesn't work sensibly.