//Storage.cpp //Stephen Bassoli //CSE 258 #include "Memory.h" #include #include #include #include "Token.h" int main() { char line[200], filename[100], ofilename[100]; int i = 0, choice; CString lines[200]; cout << "Type the name of the input file: "; cin >> filename; cout << "Type the name of the output file: "; cin >> ofilename; cout << "1) First-fit\n2) Next-fit\n3) Best-fit\n4) Worst-fit\nSelect fit method: "; cin >> choice; if ((choice < 1)||(choice > 4)) cout << "Invalid choice, First-fit will be used\n"; ifstream infile(filename); ofstream outfile(ofilename); outfile.clear(); while (infile.getline(line,200,'\n')) lines[i++] = line; Memory memory(lines, i, outfile); int j =0; while ((memory.numProgsLeft)||(memory.currPrograms)) { memory.fixSizes(); switch (choice) { case 1: if (memory.loadFirstFit()); else memory.clockEdge(); break; case 2: if (memory.loadNextFit()); else memory.clockEdge(); break; case 3: if (memory.loadBestFit()); else memory.clockEdge(); break; case 4: if (memory.loadWorstFit()); else memory.clockEdge(); break; default: if (memory.loadFirstFit()); else memory.clockEdge(); break; } memory.fixSizes(); outfile << endl; outfile << "Step: " << memory.stepsDone << endl; memory.printProgs(); memory.printHoles(); outfile << endl; j++; } outfile.close(); cout << "Jobs completed in "<< memory.stepsDone << " steps." << endl; cout << "Results have been written to " << ofilename << endl; return 0; }