get character without enter/stdin-buffer
Hi all!
Sorry for asking a simple question. I want to input a single character without enter (like getchar() does it). Conio.h (with _getch()) seems to be a Turbo-C-Include. Is there a (simple) alternative to curses/ncurses (which I used to use)? - My aim is it to produce small binaries. TIA Lea |
It's the terminal that requires you to press enter and not getchar(). You need to modify the behavior of you terminal and turn off canonical mode . Take a look at my post (the last one) in this thread, it should answer your question:
http://www.linuxquestions.org/questi...enter+terminal |
Thanks crabboy
I solved it your "easy way" with a system call system("stty -icanon -echo"); and before leaving the program system("stty icanon echo"); Lea |
Wow, that stty command really helps!
A curses alternative I find useful is the ANSI driver. For example, outputing "Esc[30m" to the terminal changes the foreground color to black. I've written all the ANSI driver calls I know of in macro form: Code:
#define cursor_moveyx(y,x) printf("\033[%d;%dH",y,x) /*Move cursor to position y,x (rows, columns) with (1,1) as origin*/ |
All times are GMT -5. The time now is 07:55 PM. |