[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reading char without waiting for \n



On Mon, 16 Feb 1998, Erez Doron wrote:

> HI
> 
> I've used getchar() ( which is a macro for getc(stdin) ) to read a char
> from the keyboard, but it did not return after a key was pressed.
> the function returned only after i pressed <enter>
> 
> how do i make it return after a key is pressed ?

Change your tty to char mode.  (the default is always line mode.)
You can do it with stty or direct tty fcntl/ioctl (don't remember which).

> 
> Regards
> Erez.
>