|
楼主 |
发表于 2006-5-25 20:35:54
|
显示全部楼层
感谢楼上兄弟的提示,我们操作系统课设结束了,我们老师提供一个有用的函数来和大家共享.以后大家就再也用不着curse库里那个难使用的getch函数了.注意!用之前要#include<termios.h>[code:1]int getch() /*a simulation of the function getch in the windows programming*/
{
struct termios oldt,newt;
int ch;
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO | ECHOCTL | IEXTEN | ISIG);
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
ch = getchar();
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
return ch;
}[/code:1] |
|