Hi ,I have trable with deletiing all records in linked listCode:void dell(record **head) { while(*head!=NULL) { * head=(*head)->next; } free(*head); }
Thank you for the help
Hi ,I have trable with deletiing all records in linked listCode:void dell(record **head) { while(*head!=NULL) { * head=(*head)->next; } free(*head); }
Thank you for the help
You need to utilize a temporary pointer to point to next element before freeing it:
Code:record *rnext; while(*head) { rnext = (*head)->next; free(*head); *head = rnext; }
If you understand what you're doing, you're not learning anything.
Thanks a lot
Quzah.Code:void nom( struct node *n ) { if( n ) { nom( n->next ); free( n ); } }
Hope is the first step on the road to disappointment.
Sometimes recursion really is more elegant.
If you understand what you're doing, you're not learning anything.