Our group has been banging our head against the wall in this one and cannot seem to figure it out. Our program is to be able to set up menus (done), allow user(s) to input 'student names' and save them to a data (*.dat) file and add names to the data file later (done), and be able to enter grades at any time. The problem that we are having is that we can enter grades fine IF the program is still running. As soon as we close the program, re-open the program, and then enter new test scores for the students, it clears the previous scores entered in the first program execute. I will paste our block of code (the function we call to do this for us). Note: I am new to the forum so if the code does not look desirable I am very sorry.
void enterQuiz (int quiz)
{
nameFile.open("Names.dat", ios::in);
if (nameFile.fail())
cout << "name file failed to open" <<endl;
//quizFile.open("quiz.dat", ios::out);
nameFile.getline (studentNames[0], nameLnth, '\n');
for(int i=0; i < 50 && strlen(studentNames[i]) > 0; i++)
{
cout << "Enter quiz # " << (quiz + 1 ) << " for " << studentNames[i] << " " << endl;
cin >> (studentAvgQuiz[i][quiz]);
for(int col=0; col < quizsize; col++)
{
quizFile << studentAvgQuiz[i][col] <<' ' ;
}
//quizFile << endl;
nameFile.getline (studentNames[i +1], nameLnth, '\n');
} //end for loop
cin.get();
nameFile.clear();
quizFile.close();
nameFile.close();
}
...Any kind of help or follow-up to help us in getting our data straightened out would be GREATLY appreciated. What we are trying to do is to run the program, enter data, close the program, re-run the program, keep the old data in and add or replace existing data to the quiz.dat file. Thanks for everyone's help! Also note that 'studentNames', 'nameLnth', and 'studentAvgQuiz' are all arrays defined globally in our program