Commit | Line | Data |
---|---|---|
e3c5dfdb KM |
1 | .\" @(#)getc.3 4.1 (Berkeley) %G% |
2 | .\" | |
3 | .TH GETC 3S | |
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 | |
34 | .I Getchar() | |
35 | is identical to | |
36 | .IR getc(stdin) . | |
37 | .PP | |
38 | .I Fgetc | |
39 | behaves like | |
40 | .I getc, | |
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 | |
46 | word (32-bit integer on a VAX-11) from the named input | |
47 | .IR stream . | |
48 | It returns the constant | |
49 | .SM | |
50 | .B EOF | |
51 | upon end of file or error, but since that is a good | |
52 | integer value, | |
53 | .I feof | |
54 | and | |
55 | .IR ferror (3) | |
56 | should be used to check the success of | |
57 | .IR getw . | |
58 | .I Getw | |
59 | assumes no special alignment in the file. | |
60 | .SH "SEE ALSO" | |
61 | fopen(3), putc(3), | |
62 | gets(3), scanf(3), | |
63 | fread(3), | |
64 | ungetc(3) | |
65 | .SH DIAGNOSTICS | |
66 | These functions return the integer constant | |
67 | .SM | |
68 | .B EOF | |
69 | at end of file or upon read error. | |
70 | .PP | |
71 | A stop with message, | |
72 | `Reading bad file', means an attempt has been made to | |
73 | read from a stream that has not been opened for | |
74 | reading by | |
75 | .IR fopen . | |
76 | .SH BUGS | |
77 | The end-of-file return from | |
78 | .I getchar | |
79 | is incompatible with that in UNIX editions 1-6. | |
80 | .PP | |
81 | Because it is implemented as a macro, | |
82 | .I getc | |
83 | treats a | |
84 | .I stream | |
85 | argument with side effects incorrectly. | |
86 | In particular, | |
87 | `getc(*f++);' | |
88 | doesn't work sensibly. |