当我运行代码时,不会提示用户输入我想要的内容。打开一个可以输入的文本框,但输入后...说出你的名字..然后按Enter键,没有任何反应。具体问题是用户没有收到任何提示,这些提示稍后将被插入到我的代码底部的“故事”中。
#include <iostream>
#include <string>
using namespace std;
int main()
{
//list of variables to be stored
string Name;
string City;
int Age;
string College;
string Job;
string Animal;
string petName;
//user prompts to be answered by user input
cin >> Name;
cin >> City;
cin >> Age;
cin >> College;
cin >> Job;
cin >> Animal;
cin >> petName;
//The output story which will include the user input as part of the final result
cout << "There once was a person named " + Name + " who lived in " + City + "." "At the age of " << endl;
cout << Age + ", " + Name + " went to college at " + College + "." + Name + " graduated and went to work" << endl;
cout << " as a " + Job + ". Then," + Name + " adopted a(n)" + Animal + " named " + petName + ". They" << endl;
cout << "both lived happily ever after!";
}
答案 0 :(得分:1)
//user prompts to be answered by user input
cout << "Enter your name:";
cin >> Name;
cout << "Enter your City:";
cin >> City;
cout << "Enter your Age:";
cin >> Age;