View Full Version : c++ remove duplicate nodes in linked list


gram1234
03-16-03, 07:05 AM
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;
}
}