1 // From http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1042856625&id=1043284385
2 // Edited by Hu Xuesong @ Thu Apr 28 CST 2011
11 inline int mygetch ( void ) {
13 struct termios oldt
, newt
;
15 tcgetattr( STDIN_FILENO
, &oldt
);
17 newt
.c_lflag
&= ~( ICANON
| ECHO
);
18 tcsetattr( STDIN_FILENO
, TCSANOW
, &newt
);
20 tcsetattr( STDIN_FILENO
, TCSANOW
, &oldt
);
25 int pressAnyKey (void) {
26 if ( !isatty(STDIN_FILENO
) )
27 return -2; // # define EOF (-1) in <stdio.h>
28 // other errno in /usr/include/asm-generic/errno-base.h
29 fputs("\nPress any key to continue ... ", stderr
);