【发布时间】:2023-03-24 19:40:01
【问题描述】:
我刚开始上入门级 C++ 课程,我正在做我的第一份家庭作业。代码似乎工作得很好,除了当输入中包含一个空格时,它只是跳过输入所在行之后的其余问题。
我希望这是有道理的!
// This program prompts the user a few general questions about themselves, the date, which IDE they are using, and which machine they have downloaded the IDE on to.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string userName, currentDate, softwareName, machineName;
//Ask the user his name.
cout << "What is your name? ";
cin >> userName;
//Ask the user the date.
cout << "What is the date? ";
cin >> currentDate;
//Asks the user which software he downloaded.
cout << "What is the name the IDE software you downloaded? ";
cin >> softwareName;
//Asks the user which machine he downloaded his IDE on.
cout << "Which machine did you download the IDE on? (ie. home computer, laptop, etc.) ";
cin >> machineName;
//Prints out the users inputs going downwards.
cout << "" << userName << endl;
cout << "" << currentDate << endl;
cout << "" << softwareName << endl;
cout << "" << machineName << endl;
return 0;
}
【问题讨论】:
标签: c++