read key from keybord in c
Hallo,
is there any ansi-c-function, that just read one char from keyboard and returns this value? Functions I know are getc(), fgetc() and getchar(); but all this functions read from stdin until carry return and sends every char to stdout like scanf(). I need function, that do following: - waits until one key is pressed, - reads value of this key from stdin, - does not output this char to stdout, - returns ascii value, So I need something like PASCAL's readkey(); Thanks for help :) |
You have to change the terminal to non-buffered I/O. You can do this with the termios() function. The man page might not give you enough details but there's a ton of sample code doing it if you do a google search search on "non-buffered termios".
|
there's something like it in
the ncurses library i think. billy |
Hi,
this might work: Code:
/* readchar.c |
How I did it
I used the following code in an application:
Code:
#include <stdio.h> Code:
char c = '\n'; //Just anything not equal to '\0' |
What about kbhit()
Is there something like this or i am wrong ?? |
That a DOS thing from the Borland compilers.
See these forum threads on how make a function like kbhit() for Linux: http://www.linuxquestions.org/questi...archid=1682323 |
All times are GMT -5. The time now is 02:13 PM. |