在此程序中接受用户输入时,Getline根本对我不起作用?我还要如何同时为getline输入多个输入?

时间:2019-03-06 01:45:22

标签: c++ iostream getline

#include <iostream>
using namespace std;

int main()
{
// Part A
 int day;
 char month[256];
 int year;
 char name[256];
 char state[2];

 cout << "Please enter your name." ;
 cin >> name;

 cout << "Please enter the month (not the number), day, and the 
 year.";
 cin >> month >> day >> year;

 cout << "Please enter the state you are located in.";
 cin.getline(state, 256);

好的,所以我需要输入一个州(美国州)的信息。当我运行它时,它只是跳过应该询问状态的地方。到底出了什么问题?

我还将如何正确格式化getline以获取多个输入(如您所见):

cin >> month >> day >> year;

在Cinline无法正常工作以及如何获得多个输入的情况下,Cant似乎找不到答案,这让我感到沮丧。我快要哭了!请帮助

0 个答案:

没有答案