[net.lang.c] Single char input using getchar

guy@rlgvax.UUCP (Guy Harris) (12/31/83)

	There's nothing wrong with using getchar for single character
	input.  The stdio package treats terminals differently than it
	does other devices.  Terminal I/O will not be buffered by getchar
	or putchar or any other stdio routine unless you request buffering
	with setbuf().  The only buffering you have to worry about is
	that controlled by ioctl.

Correction: terminals are treated differently by stdio only on output
(and, at least on 4.1cBSD, only on standard output, not on other streams;
I believe this is true of most stdio).  Stdio will do a "read" system call
asking for a bufferful; however, the buffering shouldn't matter because a "read"
system call on a terminal in "CBREAK" mode will return as soon as any
input is available.  In "~ICANON" mode (under the USG driver) the number of
characters that must be received before the wakeup occurs can be tuned.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy

perl@rdin.UUCP (Robert Perlberg) (01/04/84)

WOOOOOOOOOOOOOOOOOOOOOOAAAAAAAAAAA!!!!!

There's nothing wrong with using getchar for single character
input.  The stdio package treats terminals differently than it
does other devices.  Terminal I/O will not be buffered by getchar
or putchar or any other stdio routine unless you request buffering
with setbuf().  The only buffering you have to worry about is
that controlled by ioctl.

Robert Perlberg
Resource Dynamics Inc.
New York
philabs!rdin!rdin2!perl