当我输入程序中的输入计算机吐出“0”而不是预期的输出时,我很难运行这个C ++代码。
#include <iostream>
using namespace std;
int main()
{
int name;
cout << "Enter your name";
cin >> name;
cout << "That name fits you well, " << name;
return 0;
}
答案 0 :(得分:3)
将您的名称变量从int声明为字符串
std::string name;
cout << "Enter your name";
cin >> name;
cout << "That name fits you well, " << name;
return 0;