this is my code. in running i can not cin!! i want to cin name by space please helppppp! thanks for helping this is my code. in running i can not cin!! i want to cin name by space thanks for helping please helppppp!
struct Tamin{
string name;
int insnum;
};
struct Date{
int year, month, day;
};
void ReadInfo(Tamin [],Date [],int);
void PrintInfo(Tamin [],Date [],int,int);
int main(){
int y;
cout << "Plz enter current year : ";
cin >> y;
int n;
cout << "Plz enter number of workers : ";
cin >> n;
Tamin person[n];
Date persond[n];
ReadInfo(person, persond, n);
cout << "Displaying data... \n";
PrintInfo(person, persond, n, y);
return 0;
}
void ReadInfo(Tamin a[], Date b[], int n) {
for (int i = 0; i < n; i++) {
cout << "Plz enter Name : ";
getline(cin,a[i].name); //error is here
cout << "Plz enter Insurance Number : ";
cin >> a[i].insnum;
cout << "Plz enter Date of insurance : ";
cin >> b[i].day >> b[i].month >> b[i].year;
}
}
void PrintInfo(Tamin a[],Date b[], int n, int y) {
int yf;
cout << "Workers' Information: \n";
for (int i = 0; i < n; i++) {
cout << "Name : " << a[i].name << endl;
cout << "Insurance Number : " << a[i].insnum << endl;
cout << "Date of Insurance : " << b[i].year << "/" << setfill('0') << setw(2) << b[i].month
<< "/" << setfill('0') << setw(2) << b[i].day << endl;
yf = y - b[i].year;
cout << "Workers' record :" << yf << endl;
cout << "=========================================== \n";
}
}