Jaki jest najprostrzy sposób na wykrywanie w aplikacji konsolowej naciśnięcia przycisku tak żeby działało na windows i linux?
0
0
gconio.h
lub
ncurses
0
#ifdef UNIX
# include <termios.h>
# include <unistd.h>
int getch(void)
{
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;
}
#else
# include <conio.h>
#endif