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