Nodes and stuff.

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.

if it helps here is the source code i'm using:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <cctype>
using namespace 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
}
bump
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.
Topic archived. No new replies allowed.