?????C++?????????????????????????е????
???????????? ???????[ 2015/10/15 13:21:27 ] ??????????? .NET
????????????
????Adam?????????????????????????????????????????????? C/C++ ?У??????????У???????????????????????????????????
??????????????e????????????????????????????????????????????Enter????ü???????
????????????? Johannes Schaub – litb??
????????C++???????????????????????????????????????????????????????????????stdin????????л??壩???????????????Щ???????????????
????1.Windows ??????????? conio????? _getch() ??????????????????????????????????????Windows?????п?????????????????????????????? conio.h ?????????????????????????? conio.h ???????г??? getch() ???? Visual C++ ??????? deprecated??????????????
????2.Linux ?п?????? curses???? Windows ?????????ü???? curses ????????? conio ???????? getch() ????????????? man getch ???????? manpage??????????????????????????? Curses??
??????????????????????????е?????????????? curses??????????????Щ????????????л???????????????????y???“????”????“?????”??????????? man stty ?в?????Curses ???????????????????а???????????
????????е??Щ???????
????????Kay??
??????δ?????? kbhit() ????????????£????? getch() ?????????????
????#include <conio.h>
????if (kbhit()!=0) {
????cout<<getch()<<endl;
????}
????????Falcon Momot??
?????? Linux???????????? UNIX ?????п???????????
#include <unistd.h>
#include <termios.h>
char getch() {
char buf = 0;
struct termios old = {0};
if (tcgetattr(0?? &old) < 0)
perror("tcsetattr()");
old.c_lflag &= ~ICANON;
old.c_lflag &= ~ECHO;
old.c_cc[VMIN] = 1;
old.c_cc[VTIME] = 0;
if (tcsetattr(0?? TCSANOW?? &old) < 0)
perror("tcsetattr ICANON");
if (read(0?? &buf?? 1) < 0)
perror ("read()");
old.c_lflag |= ICANON;
old.c_lflag |= ECHO;
if (tcsetattr(0?? TCSADRAIN?? &old) < 0)
perror ("tcsetattr ~ICANON");
return (buf);
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11