I want to read every keystroke from a console application written in c under windows and linux immediately. Unfortunately the function gets(line) does only return a value, when
The following code worked for me. Thank you for pointing me into to right direction. http://bytes.com/topic/c/answers/503640-getch-linux
#include
#include
int mygetch(void)
{
struct termios oldt,
newt;
int ch;
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
ch = getchar();
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
return ch;
}