Research V4 release
[unix-history] / man / man3 / getchr.3
CommitLineData
d7d04d31
KT
1.th GETCHAR III 4/7/73
2.sh NAME
3getchar \*- read character
4.sh SYNOPSIS
5.ft B
6getchar( )
7.br
8.ft R
9.sh DESCRIPTION
10.it Getchar
11provides the simplest means of reading characters from
12the standard input for C programs.
13It returns successive characters until end-of-file,
14when it returns ``\\0''.
15.s3
16Associated with this routine is an external variable
17called \fIfin\fR, which is a structure containing
18a buffer such as described under \fIgetc\fR (III).
19.s3
20Normally input via \fIgetchar\fR is unbuffered,
21but if the file-descriptor (first) word of
22.it fin
23is non-zero,
24.it getchar
25calls
26.it getc
27with
28.it fin
29as
30argument.
31This means that
32.s3
33 fin = open(...)
34.s3
35makes
36.it getchar
37return (buffered) input from
38the opened file; also
39.s3
40 fin = dup(0);
41.s3
42causes the standard input to be buffered.
43.s3
44Generally speaking,
45.it getchar
46should be used only for the simplest applications;
47.it getc
48is better when there are multiple input files.
49.sh "SEE ALSO"
50getc (III)
51.sh DIAGNOSTICS
52Null character returned on EOF or error.
53.sh BUGS
54\*-1 should be
55returned on EOF; null is a legitimate character.