Disable line buffer and input echo of stdin
* Disable line buffer and input echo of stdin
*/
static int __getch()
{
char ch;
struct termios old, new;
(void) tcgetattr(STDIN_FILENO, &old);
memcpy(&new, &old, sizeof(struct termios));
new.c_lflag &= ~(ICANON | ECHO);
(void) tcsetattr(STDIN_FILENO, TCSANOW, &new);
ch = getchar();
(void) tcsetattr(STDIN_FILENO, TCSANOW, &old);
return ch;
}
posted on 2015-09-07 10:53 DayAfterDay 阅读(204) 评论(0) 编辑 收藏 举报