该头文件是用于检测键盘输入的,在windows下,c++标准库是自带的,但是在Linux下没有该头文件,可以通过手动的方式进行添加。步骤如下:
1、打开终端,
sudo gedit
2、在弹出的文件里输入以下代码
#include <termios.h>
#include <stdio.h>
static struct termios old, new;
/* Initialize new terminal i/o settings */
void initTermios(int echo)
{undefined
tcgetattr(0, &old); /* grab old terminal i/o settings */
new = old; /* make new settings same as old settings */
new.c_lflag &= ~ICANON; /* disable buffered i/o */
new.c_lflag &= echo ? ECHO : ~ECHO; /* set echo mode */
tcsetattr(0, TCSANOW, &new); /* use these new terminal i/o settings now */
}
/* Restore old terminal i/o settings */
void resetTermios(void)
{undefined
tcsetattr(0, TCSANOW, &old);
}
/* Read 1 character - echo defines echo mode */
char getch_(int echo)
{undefined
char ch;
initTermios(echo);
ch = getchar();
resetTermios();
return ch;
}
/* Read 1 character without echo */
char getch(void)
{undefined
return getch_(0);
}
/* Read 1 character with echo */
char getche(void)
{undefined
return getch_(1);
}
/* Let's test it out */
3、点击保存,保存到 /usr/include/conio.h。如下图所示