c++ 用GetKeyState函数,之后用cin,结果刚进入cin语句还没输入,屏幕上就显示了刚才键盘上按下的所有键

2025-05-05 05:34:38
推荐回答(1个)
回答1:

你的代码不能阻止屏幕回显,可以用不缓冲且无回显的getch()实现你的要求
int main()
{
string s;
char c = 0;
while (1)
{
c = getch(); //使用getch要#include
if (c == '1')
break;
}
cin >> s; //语句3
cout << s; //语句4
system("pause");
}