c++ remove duplicate nodes in linked list

Discussion in 'Computer Science & Culture' started by gram1234, Mar 16, 2003.

Thread Status:
Not open for further replies.
  1. gram1234 Registered Member

    Messages:
    18
    c++ linked list
    I'm trying to write a function to remove a duplicate from a linked list,just can't get it right ,beginner.Any help would be appreciated,function prototype is:void delrep(Node* head)
    parameters have to be as they are. I am stuck,and have been for a while.
    here's my code:

    void delrep(Node* &head)
    {
    Node* ptr;
    if(head!=NULL)
    {
    ptr=head;
    head=head->link;
    delete ptr;ptr=NULL;
    }
    }
     
Thread Status:
Not open for further replies.

Share This Page