#include <stdio.h>
#include <termios.h>
#include <unistd.h>
int getch()
{
struct termios tm,tm_old;
int fd = STDIN_FILENO,c;
setbuf(stdin,NULL);
if (tcgetattr(fd, &tm) < 0)
{
return -1;
}
tm_old = tm;
cfmakeraw(&tm);
if (tcsetattr(fd,TCSANOW, &tm) < 0)
{
return -1;
}
c = fgetc(stdin);
if (tcsetattr(fd,TCSANOW,&tm_old) < 0)
{
return -1;
}
return c;
}
int main()
{
system("clear");
printf("按任意键退出。。。\n");
getch();
return 0;
}
按任意键返回(退出)
最新推荐文章于 2022-10-23 16:48:18 发布