I am still trying to hammer out some details to speed up my programming. When I need to take a couple of nodes/pointers to nodes, and pass them into a function that is being called in main, where do I include the asterisks if at all? I am building a list, and then trying to create a separate function that takes a new node and the head of the list as parameters, and then inserts the new node directly after the head of the list (so the new node is the first part of the list.)
Here is my code with comments. I am getting a clash with the type node and type Ptrtype, but am not quite sure where to repair this:
void Insert(ptrType *headNode, ptrType *newNode)//parameters wrong here???
{
if (headNode->next = NULL)//if list is empty...
{
headNode->next = newNode;//forward link
newNode->prev = headNode;//back link
newNode->next = NULL;//indicates end of list
}
else//if list is not empty...
{
newNode->next = head->next;
head->next->prev = newNode;
newNode->prev = head;
head->next = newNode;
}
};
int main()
{
//in order to text this, I need to have a list to test with.
//this is the list:
ptrType nodeA = new node;
ptrType nodeB = new node;
ptrType nodeC = new node;
ptrType cur = new node;
ptrType head = new node;
ptrType newNode = new node;//new node that will be added later