好的,所以当我遇到以前从未遇到过的问题时,我只是在做一些练习。
#include <iostream>
using namespace std;
int main()
{
string empname = "";
int empage = 0;
char yes = 'y';
cout << "Please enter employee name:" << endl;
cin >> empname;
cin.get();
cout << "Your name is " + empname + " is this correct? (yes/no):" << endl;
if (yes)
{
cout << "good" << endl;
}
else
{
cout << "Please try again" << endl;
}
cout << "Please enter employee age:" << endl;
cin >> empage;
cin.get();
cout << "Your age is " + empname + " is this correct? (yes/no):" << endl;
if (yes)
{
cout << "good" << endl;
}
else
{
cout << "Please try again" << endl;
}
}
这作为控制台程序执行,但在第 11 行 [包括空格] (cout << "请输入员工姓名:\t" << endl;) 之后,它只是跳过所有内容,并说按 ENTER 继续。我究竟做错了什么。