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