[code] #include
#include
#include
int mygetch(void)
{
int ch;struct termios oldt;
struct termios newt;
tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;/** Unset the CANONICAL mode, in which input is available immediately,* and the ECHO mode.*/
newt.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
ch = getchar();
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
return ch;
}
int main(int argc, char * argv[])
{
printf("Press any key to continue...\n");
mygetch();
return 0;} [/code]
crazyrhino 于 2012-03-27 15:24:04发表:
这个模拟的getchar()还比较靠谱,顶一个
sonr 于 2011-12-03 08:51:05发表:
路过