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

Re: reading char without waiting for \n



Erez Doron <erez@savan.com> writes:

> 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 ?
> 

1. You say "RTFM" - one hundred times.
2. You write "RTFM" - one hundred times
3. You RTFM (Unix programming FAQ in this case) - two times:

	http://www.erlenstar.demon.co.uk/unix/

4. You ask yourself a question whether it is worth waiting for a
keypress. Maybe a "yes/no" answer would do. or instead the application
must use curses.
5. You implement your solution
6. GOTO #1 (considered harmful)

-- 
Alexander L. Belikoff
Berger Financial Research Ltd.
abel@bfr.co.il