linked list help

ilovec..'s Avatar, Join Date: Nov 2006
Light Poster
hi there people.

i have a linked list in which i want to delete a particular node. I have created this function and it works.

I pass the linked list (head) and the node to be deleted(which is called 'current') into the delete function.
The delete function returns the new head of the list after the particular node has been deleted.

I have printed the list which comes back from the delete function and it works fine. Ie, it doesnt print the deleted node. the current node is now meant to be the node after the deleted node. the problem is, this current is not updated into main. the current still remains as the deleted node.

how do i pass the new current node back into main as well so that it is printed. when it prints the current node is meant to have like an (->) to it. thanks.

what i pass into function:
list = free_node(list,current);
what the function receives
void* free_node(TDnode *head, TDnode *current )
The function retrns the head of the list in the format:
return (head);
In the function, the current node is updated, but i dont know how to return it into main since the head is already being returned. i can either return the current node or the head. but the list is not updated if i return the head and i need to update it.
0
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
You have posted the query in C# forum and I have moved it to C-C++ forum.