Hi all,
I am new in C programming, currently learning about linked list. I know that there is a lot of examples about linked list, but I decided to write my own code, to make me more understand. I managed to build a linked list, insert a new node after one cell, but I have a segmentation fault after deleting one node.
Can anyone help me with this, why I got segmentation fault ?
The code snippet (just for the delete block)
void cell_delete(int a)
{
cell *p, *q;
p=header.next;
q=&header;
printf("you are before while block\n");
while((p!=NULL))
{
q=p;
p=p->next;
if(p->value = a)
{
printf("correct value\n");
p=q->next;
q->next = p->next;
print_list();
free(p);
free(q);
}
else
{
printf("value of p is wrong");
}
}
printf("you are OUT OF while block\n");
}