Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site sjuvax.UUCP Path: utzoo!linus!philabs!seismo!harpo!floyd!clyde!akgua!psuvax!burdvax!sjuvax!bbanerje From: bbanerje@sjuvax.UUCP (B. Banerjee) Newsgroups: net.lang.c Subject: Re: 1-char input in C Message-ID: <219@sjuvax.UUCP> Date: Sat, 24-Dec-83 20:33:07 EST Article-I.D.: sjuvax.219 Posted: Sat Dec 24 20:33:07 1983 Date-Received: Mon, 26-Dec-83 01:07:17 EST References: <463@ihuxn.UUCP> <3755@genrad.UUCP> Organization: Saint Josephs U. Philadelphia, PA Lines: 24 >>(and easiest to understand) is to use the system() call to change the >>tty mode as follows: >>#include >>main() { >> system("stty raw"); /* dont buffer data */ >> getchar(); >> system("stty -raw"); /* restore normal buffering */ >>} >> >>The other option is to use ioctl() (or gtty & stty on systems that have >>it) to set the tty modes properly. The problem with this is that BELL, >>BSD and V7 systems are all different in the exact format of these >>ioctl()'s Nice solution. I was about to suggest mucking around with ioctl(). However, if I remember correctly from K & R, getchar() and putchar() buffer their input/output respectively. It might be best to use read() instead. -- Binayak Banerjee {allegra | astrovax | bpa | burdvax}!sjuvax!bbanerje