tetramethrin
Programmer
I have thsi code so far, It seems correct but when ran it causes an application error, saying that memory cannot be read from a certain location
Any ideas?
void delrep (node *&head)
{ node *previous = head;
for (node *head2 = head ; head2->link != NULL;head2=head2->link)
{
for (node *compare =head->link;compare ->link !=NULL; compare=compare ->link)
{
if ( compare ->data == head2->data)
{
previous->link = compare->link;
delete compare;
if(compare->link == NULL)
break;
}
previous = compare;
}
}
}
Any ideas?
void delrep (node *&head)
{ node *previous = head;
for (node *head2 = head ; head2->link != NULL;head2=head2->link)
{
for (node *compare =head->link;compare ->link !=NULL; compare=compare ->link)
{
if ( compare ->data == head2->data)
{
previous->link = compare->link;
delete compare;
if(compare->link == NULL)
break;
}
previous = compare;
}
}
}