Can anyone help? It's not closing the file when I'm reading in a file. I'm using a Linked List implementation where list.Insert(temp) is a function to add that Student to the list.
int ProcessFile(List &list){
int j = 0;
Student temp;
ifstream infile;
infile.open("ClassRoster.data"); //Open ClassRoster.data
if (infile.fail()){
cout<<"Could not read file.\n"; //Display this if file does not open
exit(1);
}
infile>>temp.id; //Read in the first item of ClassRoster.data
while(!infile.eof())
{
getline(infile, temp.Name, '$');
infile>>temp.managerStat;
list.Insert(temp);
j++;
cout<<j<<endl;
infile>>temp.id; //Read in the first item of ClassRoster.data
}
infile.close(); //Close file
return j;
}