bool InsertResult(char *filename, List<Student> *list) { Student stu; Exam exam; bool read=true; char stuid[10]; ifstream in; in.open(filename); if(!in){ cout << "The file cannot open." << endl; read = false; //set the read to false when the file not found } while(!in.eof()) { int check=1; in >> stuid; for(int i=1; i<=list->size(); i++) { list->get(i,stu); if(strcmp(stu.id,stuid) == 0) { check = 0; break; } } in >> exam.trimester; in >> exam.year; in >> exam.numOfSubjects; for(int i=0;i<exam.numofsubjects;i++)> { in>>exam.sub[i].subject_code; in>>exam.sub[i].subject_name; in>>exam.sub[i].credit_hours; in>>exam.sub[i].marks; } //////////////////////////////////Problem in here ///////////////////////////////// if (check==0) { if(list->find(stu)->item.exam->empty()) { list->find(stu)->item.exam = new List<exam>; list->find(stu)->item.exam->insert(exam); } else list->find(stu)->item.exam->insert(exam); } //////////////////////////////////////////////////////////////////////////////// for(int i=1; i<=list->size(); i++) { list->get(i,stu); if(strcmp(stu.id,stuid) == 0) { exam.calculateGPA(); stu.calculateCurrentCGPA(); list->set(i,stu); cout << stu; } //cout << exam; } } in.close(); cout << "\n\t Student results are successfully inserted.\n"; return true; }
Quote:bool InsertResult(char *filename, List<student> *list)
bool InsertResult(char *filename, List<Student> *list)
list->find(atoi(stuid))
list->find(stu)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)