这是一个非常简单的应用程序来说明我遇到的问题。
#include <QTextStream>
int main()
{
QTextStream cin(stdin);
QTextStream cout(stdout);
QString test;
cout << "Enter a value: ";
cout.flush();
cin >> test;
cout << "Enter another value: ";
cout.flush();
test = cin.readLine();
cout << test;
return 0;
}
我希望执行暂停并等待输入test = cin.readline();
,但事实并非如此。如果我删除cin >> test;
然后它会暂停。
为什么这段代码会有这样的行为,我如何获得我想要的行为?