linked list help

Discussion in 'C' started by ilovec.., Nov 2, 2006.

  1. ilovec..

    ilovec.. New Member

    Joined:
    Nov 2, 2006
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,376
    Likes Received:
    388
    Trophy Points:
    83
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,376
    Likes Received:
    388
    Trophy Points:
    83
    You have posted the query in C# forum and I have moved it to C-C++ forum.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice