I have a strange problem. The following code snippet demonstrates the problem.
I have 4 pieces of data I need to capture which I then store into the index of some arrays. The index corresponds to the "loop number".
The problem is that on the FIRST LOOP, the program falls through the first GETLINE without waiting for input. It displays "EnterStudent Name" then immediately displays "Enter student ID" (the second element).
After the ForNEXT loop goes throught the first iteration, it works properly.
It's almost like the default delimiter is being reached on the first pass without typing anything.
Any help would be appreciated.
void readData (string studentName , string studentId , float score ,
int limit, const int MAX_SIZE)
const int highest = 100;
const int lowest = 0;
int temp = 0, validGrade = 0;
for(int i = 0; i < limit; i++)
cout << "Enter the students name: ";
getline(cin,name); <========================Problem Here on 1st loop. Program doesnt stop here on first pass
studentName[i] = name;
cout << "Enter " << studentName[i] << "'s i.d: ";
studentId[i] = id;
cout << "Enter " << studentName[i] << "'s grade: ";
cin >> temp;
validGrade = validateData(temp, highest, lowest);
score[i] = validGrade;