#include #include #include using namespace std; struct SUBJECT{ int id; string subjectname; int quota; }; SUBJECT allSubjects[20]; int totalsubject = 0; void readSubjects(){ ifstream inputFile("subjects.txt"); string t; int quota, total=0; if (!inputFile.is_open()) { cerr << "Error: could not open file." << endl; } while (getline(inputFile, t)) { cout << "subj:" << t << endl; allSubjects[total].id=total; allSubjects[total].subjectname=t; if (getline(inputFile, t)) { quota = stoi(t); allSubjects[total].quota = quota; } else { cerr << "Error: could not read next line." << endl; break; // Exit the loop if the integer read fails } total++; } inputFile.close(); totalsubject = total; } void printSubjects(){ for(int i=0;i "; cin >> option; }while(option <0||option>4); if(option==1){ readFile(); } else if(option==4){ printSubjects(); } }while(option != 0); return 0; }