Line | |
---|
1 | .\" @(#)getc.3s 6.2 (Berkeley) 5/14/86
|
---|
2 | .\"
|
---|
3 | .TH GETC 3 "May 14, 1986"
|
---|
4 | .AT 3
|
---|
5 | .SH NAME
|
---|
6 | getc, getchar, fgetc, getw \- get character or word from stream
|
---|
7 | .SH SYNOPSIS
|
---|
8 | .nf
|
---|
9 | .ft B
|
---|
10 | #include <stdio.h>
|
---|
11 |
|
---|
12 | int getc(FILE *\fIstream\fP)
|
---|
13 | int getchar(void)
|
---|
14 | int fgetc(FILE *\fIstream\fP)
|
---|
15 | int getw(FILE *\fIstream\fP)
|
---|
16 | .ft R
|
---|
17 | .fi
|
---|
18 | .SH DESCRIPTION
|
---|
19 | .B Getc
|
---|
20 | returns the next character from the named input
|
---|
21 | .IR stream .
|
---|
22 | .PP
|
---|
23 | .BR Getchar ()
|
---|
24 | is identical to
|
---|
25 | .BR getc ( stdin ).
|
---|
26 | .PP
|
---|
27 | .B Fgetc
|
---|
28 | behaves like
|
---|
29 | .BR getc ,
|
---|
30 | but is a genuine function, not a macro;
|
---|
31 | it may be used to save object text.
|
---|
32 | .PP
|
---|
33 | .B Getw
|
---|
34 | returns the next
|
---|
35 | .B int
|
---|
36 | from the named input
|
---|
37 | .IR stream .
|
---|
38 | It returns the constant
|
---|
39 | .SM
|
---|
40 | .B EOF
|
---|
41 | upon end of file or error, but since that is a good
|
---|
42 | integer value,
|
---|
43 | .B feof
|
---|
44 | and
|
---|
45 | .BR ferror (3)
|
---|
46 | should be used to check the success of
|
---|
47 | .BR getw .
|
---|
48 | .B Getw
|
---|
49 | assumes no special alignment in the file.
|
---|
50 | .SH "SEE ALSO"
|
---|
51 | .BR clearerr (3),
|
---|
52 | .BR fopen (3),
|
---|
53 | .BR putc (3),
|
---|
54 | .BR gets (3),
|
---|
55 | .BR scanf (3),
|
---|
56 | .BR fread (3),
|
---|
57 | .BR ungetc (3).
|
---|
58 | .SH DIAGNOSTICS
|
---|
59 | These functions return the integer constant
|
---|
60 | .SM
|
---|
61 | .B EOF
|
---|
62 | at end of file, upon read error,
|
---|
63 | or if an attempt is made to read a file not opened by
|
---|
64 | .BR fopen .
|
---|
65 | The end-of-file condition is remembered,
|
---|
66 | even on a terminal,
|
---|
67 | and all subsequent attempts to read will return
|
---|
68 | .B EOF
|
---|
69 | until the condition is cleared with
|
---|
70 | .BR clearerr (3).
|
---|
71 | .SH BUGS
|
---|
72 | Because it is implemented as a macro,
|
---|
73 | .B getc
|
---|
74 | treats a
|
---|
75 | .I stream
|
---|
76 | argument with side effects incorrectly.
|
---|
77 | In particular,
|
---|
78 | `getc(*f++);'
|
---|
79 | doesn't work sensibly.
|
---|
Note:
See
TracBrowser
for help on using the repository browser.