在cpp中获取数据作为输入

问题描述

我试图让用户输入数据,但是编译器跳过了cpp程序中的getline函数。可能是什么问题?这是代码


#include <iostream>

using namespace std;

struct Customer{

 char name[10];
 char email[30];
 int age ;
 int idno;
 string date;


};

int main()
{
  Customer cust;
   cout<<"Enter the name of the customer"<<endl;
   cin>>cust.name;

   cout<<"Enter the email of the customer"<<endl;
   cin>>cust.email;

   cout<<"Enter the age of the customer"<<endl;
   cin>>cust.age;

   cout<<"Enter the id number of the customer"<<endl;
   cin>>cust.idno;

   cout<<"Enter the date of birth of the customer"<<endl;
   getline(cin,cust.date);


   cout<<"The details of the customer are"<<endl;
   cout<<"Name :"<<cust.name<<endl;
   cout<<"Email :"<<cust.email<<endl;
   cout<<"Age :"<<cust.age<<endl;
   cout<<"Id number :"<<cust.idno<<endl;
   cout<<"Date of birth :"<<cust.date<<endl;

   return 0;
}

Here is the output of the program

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)