-
Deleting - Linked List
I have created a double linked list program, where I can add and display the detail in the list.
However, I need to delete the last item in the list without having to identify any value. Is this possible? Or do I have to search the link with the value.
I have tried *last = NULL;
& *last = info->prior;
Can anyone provide the general coding?
-
... is this what you're asking for?
Code:
void delLast ()
{
node * p = last -> prior;
p -> next = NULL;
free (last);
last = p;
}
or if last isn't global...
Code:
void delLast (node **last)
{
node *p = *last -> prior;
p -> next = NULL;
free (*last);
*last = p;
}
As always, no promises that it'll compile... or that it's what you're looking for. The free() s could be left out I suppose, and it would have the same noticable effect, although that is a big no-no.
-
Thanks, That's IT!!!
TeeTee:)