|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Linked Lists
I posted a message about linked lists about a week ago and have had a lot of replies. Remember I am a beginner. Mike Main's header file made no sense to me whatsoever, and I have written a file which i hoped that someone could look at and explain where I am going wrong. thanks John Oxley
#include <stdio.h>
#include <conio.h>
struct nodeType
{
int HouseNum;
nodeType * NEXT;
};
struct nodeList
{
nodeType * HEAD;
nodeType * TAIL;
int NodeNumber;
};
nodeList *list;
nodeType *node;
int main()
{
// Create the list
list=new nodeList;
list->HEAD=NULL;
list->TAIL=NULL;
// Create a new node
node=new nodeType;
node->HouseNum=5;
node->NEXT=NULL;
// Update the list;
list->HEAD=node;
list->TAIL=node;
list->NodeNumber=1;
// Create another new node
node=new nodeType;
node->HouseNum=6;
node->NEXT=NULL;
// Update the end of the list
list->TAIL=node;
list->NodeNumber=2;
printf("The list has been created with 2 entries");
getch();
node=new nodeType;
node=list->HEAD; // I think here is the problem
printf("%d",list->HouseNumber); // Here is the error
node=node->NEXT;
printf("%d",list->HouseNumber);
getch();
return 0;
}
|
|