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