#include #include static struct termios stored_settings,new_settings; int main(void) { char c; int count=1; tcgetattr(0,&stored_settings); new_settings = stored_settings; new_settings.c_lflag &= (~ICANON); new_settings.c_lflag &= (~ECHO); new_settings.c_cc[VTIME] = 0; new_settings.c_cc[VMIN] = 1; tcsetattr(0,TCSANOW,&new_settings); printf("Hit '+'/'-' key to count up/down, 'q' to exit.\n"); printf("%d\n",count); while((c=getchar()) != 'q'){ if(c == '+')count++; if(c == '-')count--; printf("%d\n",count); } tcsetattr(0,TCSANOW,&stored_settings); }