I was wondering how the format for converting a structured Array (in which the data is loaded from a text file) to a Linked List would look. And how i would edit the menu functions that run my program.
code:
(IN MAIN.CPP)
****(Function definitions left out)*****Code:#include <iostream> #include <fstream> #include <iomanip> #include <sstream> #include <string> #include <stdlib.h> #include "StudentRec.h" #include "DatabaseIO.h" #include "RecordProcessing.h" using namespace std; //Global Declaration StudentRec students[ISIZE]; ifstream inFile; int arraysize; int main() { string buffer; int selection = 0; const int NOTOK = 1; read_file(students, "studentrecord.txt"); SortStudentArray(students, ISIZE); while(selection != 5) { cout << "Please choose" << endl << "(1) Add a student record" << endl << "(2) Delete a student record" << endl << "(3) Find a student's information" << endl << "(4) Display all information in the database" << endl << "(5) Exit Program" << endl; cin >> selection; if(!cin) { cout << "You have entered an invalid selection, Terminating program!..." << endl; exit(NOTOK); } if(selection < 0 or selection > 5) { cout << "Invalid selection, Terminating program!..." << endl; exit(NOTOK); } if(selection == 1) { add_a_record(students); } if(selection == 2) { StudentRec dummy; delete_a_record(dummy); } if(selection == 3) { string ID; cout << "Please enter Student ID: "; cin >> ID; int position; position = BinarySearch(students, 0, arraysize, ID); if (position == -1) { cout << "Not Found" << endl; } else cout << students[position].Name << "\t"; cout << students[position].ID << "\t"; cout << students[position].GPA << endl; } if(selection == 4) { display_data(students); } if(selection == 5) { save_database(students, "studentrecord.txt"); } } //Ends While loop } //Ends Int main (IN STUDENTREC.H) using namespace std; struct StudentRec { string Name; string ID; double GPA; }; struct StudentListNode { StudentRec students; StudentListNode *next; }; const int ISIZE = 100;



LinkBack URL
About LinkBacks


