Hello-
I am having trouble with a program that I have written in C++. My problem is that I can't put the name information into my structure. I am able to add in the "name" the first time around, however, on the second loop it simply skips it and goes on to the "HC" input. Here is my code, can anyone tell me why it won't allow me to input a name on loop #2?
Thanks for your help!
#include <iostream>
const int Arsize = 3;
struct handicap
{
char name[20];
int hc;
}people [Arsize];
void display (handicap score);
using namespace std;
int main()
{
int i;
cout<<"Please input name and hc."<<endl;
for (i=0;i<3;i++)
{
cout<<"Name:";
cin.getline(people[i].name, 20);//<--my problem exists here on loop #2
cout<<"HC:";
cin>>people[i].hc;
}
cout<<"You have entered the following info:"<<endl;
for (i=0;i<3; i++)
display(people[i]);
return 0;
}
void display (handicap score)
{
cout<<score.name<<endl;
cout<<score.hc;
}