Ok. I have spent several hours today reading about and trying to understand nodes. And it's just not happening. I have a project due tomorrow which requires me to incorporate nodes. I get the concept behind them however it's actually putting them into play that confuses the mother-f***in bejeebers out of me. I have been trying to get it, and I can't. If you could give me some pointers (no pun intended) on how I'm supposed to go about using nodes, that would be fantastic. I'm not asking you to do this for me, just help guide me through the process.
#include <iostream>
#include <cctype>
usingnamespace std;
struct Player
{
char playerName[15];
int jerseyNumber;
int pointsScored;
Player *next;
};
void displayPlayer(Player *); // prototype of the display function
int main()
{
//declare three pointers of Player type
//one pointer to point to head node; one to point to previous node
// and one to point to new node
Player *head = NULL;
Player *pointHead;
Player *pointPrev;
Player *pointNew
pointHead = (Player*)malloc(sizeof(Player));
pointHead -> next = head;
do
{
//dynamically create a new node of Player type and make the new node pointer point to it
//enter data in to the new node (name, jersy no, score)
//set the next field of new node to NULL
if (this is the 1st node)
{
//make head node and previous node pointers equal to the new node pointer
}
else
{
//set the next member of of the previous node eqal to ne node pointer
//make previous node pointer point to the new new node
}
}while(user wants to continue);
// Call displayPlayer function with headnode pointer
}
void displayPlayer(Player *h)
{
while( not end of the list)
{
//display node content
} // set h to next node
}
If you're still having issues, I sent you a message. I struggled with the concept of pointers, and in turn nodes, for the longest time until someone helped me, so I'm just passing the generosity on.