I have a problem using the functions delete (the header cell remains) and destroy in single and double linked lists. This is the code that I used for DLL:
What I did wrong?Code:#include <stdio.h> #include <stdlib.h> #include "DLList.h" ListDT *deleteDList(ListDT *L) // deletes all the cells of the list L except the header cell; returns a pointer to header cell { NodeDT *p; while (L->first!= NULL) { p = L->first; L->first = L->first -> next; free( p ); } L->last = NULL; return L; } void destroyDList(ListDT *L) // deletes all the cells of the list L including the header cell. { NodeDT *p; p = L->first; while (p != NULL) { p = L->first; L->first=L->first->next; free( p ); } free (L); }