I don't fully understand what is wrong with my code, it will read the first lines of any text file but then overloads and keeps displaying "0.00" and then crashes the program. I'm trying to get it to read student's last names and read their GPA scores, and the sentinel value is 99.9, Please help.
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
//Declare i/o variables
ifstream inputFile;
//Declare counters
int counter = 0;
//Declare Arrays
char dataFile[20] = {""};
string studentLastName[100] = {""};
float studentGPA[100] = {0.0, };
cout << "Filename: ";
cin >> dataFile;
inputFile.open(dataFile);
cout << fixed << setprecision(2) << showpoint;
while(studentGPA[counter] < 99)
{
inputFile >> studentLastName[counter];
inputFile >> studentGPA[counter];
cout << studentLastName[counter] << endl;
cout << studentGPA[counter] << endl << endl;
counter++;
}
system("pause");
return 0;
}