Setting up a linked list?

deker9's Avatar, Join Date: Oct 2011
Newbie Member
I'm reading a text file into the program with the following format:
Code:
Becker John P
Ury Ismael C
Joker Samuel P
Sampson Kelly C
My code is below:
Code:
struct Roster {
    string LName;
    string FName;
    char Cheesecake;
    Roster *next, *prev;
};

inFile.open(file_name);

    Roster * head;

    for (int record = 0;record < numRecords;record++)
        {
            static Roster * thisRoster = new struct Roster;
            inFile >> thisRoster->LName;
            inFile >> thisRoster->FName;
            inFile >> thisRoster->Cheesecake;
            cout << (*thisRoster).LName << " " << (*thisRoster).FName << " " << (*thisRoster).Cheesecake << endl;
            

        }
My issue is that I'm not sure how to "link" these together. I'm then supposed to be able to sort by last name etc. Can someone maybe give me pointers or help me modify this code to suit those purposes?
neerjasoftwares's Avatar
Go4Expert Member
hello dear.....................
Neerja Softwares.com launched a quick series on pointers giving the explanation of each and every topic that we face daily.