1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include "conio.h" #include <termios.h> #include <unistd.h> #include <stdio.h> int getch() { struct termios oldattr, newattr; int ch; tcgetattr(STDIN_FILENO, &oldattr); newattr = oldattr; newattr.c_lflag &= ~(ICANON | ECHO); tcsetattr(STDIN_FILENO, TCSANOW, &newattr); ch = getchar(); tcsetattr(STDIN_FILENO, TCSANOW, &oldattr); return ch; }