Author Message
CathyRoberson    

Guys,

I am having trouble trying to delete the last node in a linked list program. Here is my function but it does not work properly:

void DeleteLastNode(Node *headPointer) {

Node *delFirstNode;
delFirstNode = headPointer->next;

while(delFirstNode != NULL) {

headPointer->next = headPointer->next->next;
if(delFirstNode == NULL) {
free(delFirstNode);
printf(«deleted»);
break;
}
else {
printf(«There are no nodes in the list!\n»);
}
}
}

Could someone please fix this so it works please!