That is the question,
Kindly guide !
That is the question,
Kindly guide !
Oh perhaps termios struct can be used here !
The FAQ has an example of simulating conio.h's getch function using termios.
My best code is written with the delete key.
Thanks for replying!
I forgot to mention in my OP that i am using Linux, conio.h doesn't work there !
Still I discovered a piece of code:
This code works fine with all keys except Ctrl, Alt !Code:int mygetch () { 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; }
It simpy doesn't read them . Can some one point out why ?
>I forgot to mention in my OP that i am using Linux
I assumed you were using Linux since you mentioned termios. Oh well, you can lead a newbie to the FAQ, but you can't make him read.
>conio.h doesn't work there !
I know that. Read all the way to the bottom of the FAQ and you'll find a Linux friendly example using termios. The piece of code you "discovered" looks to be a knockoff of our FAQ's version with slightly different formatting. The end result is the same, but you probably wasted more effort than was necessary by failing to read the FAQ in its entirety.
>It simpy doesn't read them . Can some one point out why ?
Perhaps because they don't do anything meaningful except in conjunction with another key? How much do you know about scancodes?
My best code is written with the delete key.
Thanks for the nice link,
I didn't read the FAQ till end because i failed to read the word simulating in your following post.
The FAQ has an example of simulating conio.h's getch function using termios.