C ++中的输入和输出

时间:2018-01-23 01:37:03

标签: c++

当我输入程序中的输入计算机吐出“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;
 }

1 个答案:

答案 0 :(得分:3)

将您的名称变量从int声明为字符串

std::string name;
cout << "Enter your name";
cin >> name;
cout << "That name fits you well, " << name;

return 0;
相关问题