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