In a program I created I need to get some customer information to an array. Below are the codes regarding my question.
struct CustomerType
{
string fName;
string lName;
char gender;
string address;
string contactNo;
};
CustomerType Customer[1000];
I have the following code to get the input from user. Here i
is the index of the customer I'm getting information about.
string add="";
cout<<left<<"\n"<<setw(29)<<"\t\t Name"<<": ";
cin>>Customer[i].fName>>Customer[i].lName;
cout<<left<<"\n"<<setw(29)<<"\t\t Gender"<<": ";
cin>>Customer[i].gender;
cout<<left<<"\n"<<setw(29)<<"\t\t Address"<<": ";
getline(cin,add); Customer[i].address=add;
cout<<left<<"\n"<<setw(29)<<"\t\t Contact No."<<": ";
cin>>Customer[i].contactNo;
But when I run the program, it only asks to input the name, gender and contact no. but not the address. It works like there is no getline
command.
How do I fix this?