1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Setting up a linked list?

Discussion in 'C++' started by deker9, Oct 14, 2011.

  1. deker9

    deker9 New Member

    Joined:
    Oct 14, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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?
     
  2. neerjasoftwares

    neerjasoftwares New Member

    Joined:
    Oct 17, 2011
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Drupal Developer
    Location:
    Jaipur, Rajasthan, India
    Home Page:
    hello dear.....................
    Neerja Softwares.com launched a quick series on pointers giving the explanation of each and every topic that we face daily.
     

Share This Page