1-char input in C
B. Banerjee
bbanerje at sjuvax.UUCP
Sun Dec 25 11:33:07 AEST 1983
>>(and easiest to understand) is to use the system() call to change the
>>tty mode as follows:
>>#include <stdio.h>
>>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
More information about the Comp.lang.c
mailing list