1 Attachment(s)
Still getting an error in deleting a node
Hi, its me again. I revised my code and tried to follow what you guys said already, but I'm still getting the stupid window popping out when I try to delete a node from a linked list. (i attached a pic if you're wondering what the window looks like)
I think the concept is right, but i dont understand why the window keeps popping out, is that normal? :\
Code:
void deleteNode(link *head, int input)
{
link p;
link dealloc;
int match=0;
if(*head==NULL)
{
printList(head);
return;
}
p=*head;
while(p!=NULL)
{
if(p->x==input)
match++;
p=p->next;
}
if(match>=1)
{
if((*head)->x == input)
{
dealloc=*head;
*head=(*head)->next;
free(dealloc);
}
else
{
dealloc=*head;
p=NULL;
while(dealloc!=NULL && dealloc->x!=input)
{
p = dealloc;
dealloc = dealloc->next;
}
p->next=dealloc->next;
free(dealloc);
}
printList(head);
}//end if
else
{
printf("NUMBER NOT FOUND!");
printList(head);
}
}