summaryrefslogtreecommitdiff
path: root/conio.h
blob: fa866f2174e15b454a8d926e166278332c6a2646 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <termios.h>
#include <unistd.h> 
#include <stdio.h> 
int getch(void) {
	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;
}