Code:
#include<termios.h>
#include<unistd.h>
int getch( )
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;
}
You can use this getch() function in C or C++ in Linux, as linux GNU libraries din't provide "Console Input Output <conio.h>". I've Written some functions of ConIO for GNU-C and this is one of that.
No comments:
Post a Comment