Confused with cin.getline

Hi, I got an issue dealing with cin.getline feature..
So, here is my code/function:

void studentRecord(char name[][300], int id[], int test1[], int test2[], char contact[][100], int size)
{
for(int i = 0; i < size; i++)
{
cout << "\nStudent No: " << (i) << endl;
cout << "\nEnter the student name: ";
cin.getline(name[i],300);
cout << "Enter the student ID: ";
cin >> id[i];
cout << "Enter the mark for Test 1: ";
cin >> test1[i];
cout << "Enter the mark for Test 2: ";
cin >> test2[i];
cout << "Enter the Contact No.: ";
cin.getline(contact[i],100);
}
}

so it was working well until the second loop begin. it skipped the enter name part. I really appreciate if you help with this problem. Anyway, you might be think that i should use struct instead of using this too many arrays!. Well, this is my assignment so i was told to use array so yeah....

-cplusx2
That getline at the end for contact No.: will be skipped just so you know. Im pretty sure of it.
Add cin.ignore(); after first loop...
At last, no more skipping....cin.ignore works like a charm!!! Thanks everyone, really appreciated it!!!!

-cplusx2
Topic archived. No new replies allowed.