Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!harpo!ihnp4!inuxc!pur-ee!uiucdcs!uiuccsb!grunwald From: grunwald@uiuccsb.UUCP Newsgroups: net.lang.c Subject: Re: 1-char input in C - (nf) Message-ID: <4883@uiucdcs.UUCP> Date: Thu, 12-Jan-84 22:28:55 EST Article-I.D.: uiucdcs.4883 Posted: Thu Jan 12 22:28:55 1984 Date-Received: Sun, 15-Jan-84 00:40:23 EST Lines: 29 #R:ihuxn:-46300:uiuccsb:9000009:000:915 uiuccsb!grunwald Jan 12 12:21:00 1984 re: using read over getchar to not buffer input While it is true that when using the STDIO package, getchar and putchar cause input to be buffered, the action that is occuring is due to the terminal device driver. If one used "read" without changing to cbreak or raw mode, you would still need to press return for the read to finish. When not using STDIO, getchar is equivilent to: getchar() { int ch; read(STDIN,ch,1); return(ch); } When using STDIO, getchar is in fact a #define macro. When it runs out of valid data in the current buffer, it calls "read" to fill up the buffer. If you're not doing a lot of mucking around, with switching between CBREAK, RAW and COOKED modes, using the "system" call is sufficient. Otherwise, you might want to look at ioctl(2) and tty(4) in the UNIX manual. Dirk Grunwald University of Illinois USENET : ihnp4 ! uiucdcs ! grunwald CSNET : grunwald.uiuc@Rand-Relay