Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1a 12/4/83; site rlgvax.UUCP Path: utzoo!linus!philabs!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.lang.c Subject: Re: Single char input using getchar() Message-ID: <1509@rlgvax.UUCP> Date: Sat, 31-Dec-83 02:53:40 EST Article-I.D.: rlgvax.1509 Posted: Sat Dec 31 02:53:40 1983 Date-Received: Sun, 1-Jan-84 02:27:20 EST References: <338@rdin.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 18 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