How do I convert this Array Program into a linked list program??
Hey Guys what i need to do is turn my current menu operated structured array of student records ( NAME, NAME, ID, GPA) that consists of Adding a student, finding a student, display all data in database, save data, load data, and deleting a student, into a linked list that has the same functionality as the structured array program. Can someone please help me?
(IN MAIN.CPP)
#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;
****(Function definitions left out)*****