I have a problem using getline in a loop. The first time that I have to enter a Address, it works. but from there on it just skips the cin for the rest of the gardens..
Output looks something like this:Code:void inputInformation(GardenInfo gardensP[])
{
for(int i=0;i<NR_OF_GARDENS;i++)
{
cout<<"Please enter the address of garden "<<i+1<<":"<<endl;
getline(cin,gardensP[i].Address,'\n');
cout<<"Please enter the weekday that we will work at garden "<<i+1<<":"<<endl;
getline(cin,gardensP[i].Day,'\n');
cout<<"Please enter the number of workers for garden "<<i+1<<":"<<endl;
cin>>gardensP[i].Workers;
do{
cout<<"Please indicate of the garden has a pool"<<endl;
cin>>gardensP[i].Pool;
}while (gardensP[i].Pool!='Y' && gardensP[i].Pool!='N');
}
}
Please enter the address of garden 1:
Long Street 12
Please enter the weekday that we will work at garden 1:
Monday
Please enter the number of workers for garden 1:
4
Please indicate of the garden has a pool
Y
Please enter the address of garden 2:
Please enter the weekday that we will work at garden 2:
Monday
Please enter the number of workers for garden 2:
6
Please indicate of the garden has a pool
N
Please enter the address of garden 3:
Please enter the weekday that we will work at garden 3:
It just skips the Address question after the first one... What am i doing wrong?
Thanks in advance
