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