| 1 | .TH GETC UCB 4/8/79 |
| 2 | .SH NAME |
| 3 | getc, getchar, fgetc, getw \- get character or word from stream |
| 4 | .SH SYNOPSIS |
| 5 | .B #include <nstdio.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 peekc(stream) |
| 16 | .br |
| 17 | .SM |
| 18 | .B FILE |
| 19 | .B *stream; |
| 20 | .PP |
| 21 | .B int peekchar() |
| 22 | .PP |
| 23 | .B int fgetc(stream) |
| 24 | .br |
| 25 | .SM |
| 26 | .B FILE |
| 27 | .B *stream; |
| 28 | .PP |
| 29 | .B int getw(stream) |
| 30 | .br |
| 31 | .SM |
| 32 | .B FILE |
| 33 | .B *stream; |
| 34 | .SH DESCRIPTION |
| 35 | .I Getc |
| 36 | returns the next character from the named input |
| 37 | .IR stream . |
| 38 | .PP |
| 39 | .I Getchar() |
| 40 | is identical to |
| 41 | .IR getc(stdin) . |
| 42 | .PP |
| 43 | .I Peekc |
| 44 | returns the next character from the named input, without advancing the pointer. |
| 45 | Note that it may cause the buffer to be filled and is inadvisable for pipes. |
| 46 | .PP |
| 47 | .I Peekchar() |
| 48 | is identical to |
| 49 | .IR peekc(stdin) . |
| 50 | .PP |
| 51 | .I Fgetc |
| 52 | behaves like |
| 53 | .I getc, |
| 54 | but is a genuine function, not a macro; |
| 55 | it may be used to save object text. |
| 56 | .PP |
| 57 | .I Getw |
| 58 | returns the next |
| 59 | word (32-bit integer on a VAX-11) from the named input |
| 60 | .IR stream . |
| 61 | It returns the constant |
| 62 | .SM |
| 63 | .B EOF |
| 64 | upon end of file or error, but since that is a good |
| 65 | integer value, |
| 66 | .I feof |
| 67 | and |
| 68 | .IR ferror (3) |
| 69 | should be used to check the success of |
| 70 | .IR getw . |
| 71 | .I Getw |
| 72 | assumes no special alignment in the file. |
| 73 | .SH "SEE ALSO" |
| 74 | fopen(3), putc(3), |
| 75 | gets(3), scanf(3), |
| 76 | fread(3), |
| 77 | ungetc(3) |
| 78 | .SH DIAGNOSTICS |
| 79 | These functions return the integer constant |
| 80 | .SM |
| 81 | .B EOF |
| 82 | at end of file or upon read error. |
| 83 | .PP |
| 84 | A stop with message, |
| 85 | `Reading bad file', means an attempt has been made to |
| 86 | read from a stream that has not been opened for |
| 87 | reading by |
| 88 | .IR fopen . |
| 89 | .SH AUTHOR |
| 90 | Peekc was a product of the laboratory for computer science, M.I.T. |
| 91 | .SH BUGS |
| 92 | The end-of-file return from |
| 93 | .I getchar |
| 94 | is incompatible with that in UNIX editions 1-6. |
| 95 | .PP |
| 96 | Because it is implemented as a macro, |
| 97 | .I getc |
| 98 | treats a |
| 99 | .I stream |
| 100 | argument with side effects incorrectly. |
| 101 | In particular, |
| 102 | `getc(*f++);' |
| 103 | doesn't work sensibly. |