I am new to programming and I can't figure out why this is only giving me the first number in the file and not filling the array. The file is just 12 numbers and its only printing out the first one. This is just going to be a function in the program but I can't get it to work. Any help is appreciated.
int main()
{
int i,quizArray[12];
int numOfQuizzes=0;
ifstream inFile;
inFile.open( "/Users/mikerizza/Desktop/quizScores.txt" );
if ( inFile.fail() )
{
cout << "The quizscores.txt input file did not open";
exit(-1);
}
while (inFile.good())
{
numOfQuizzes++;
for (int i = 0; i < 13; i++)
inFile>> quizArray[i];
}
inFile.close();
cout<<quizArray[i]<<endl<<numOfQuizzes;
}
Thank you I forgot to use the for loop when printing it out. I am only printing it out to make sure its right so I wasn't too worried about the index. The other problem I have is that the numOfQuizzes keeps coming out as 0?