I don't get an error when I compile, but I get one when I try to add a
record in this function, It has to be a recursive insert function...Can
you tell what I might be doing wrong?
void InsertItem(nodeptr *pList, nodeptr newptr)
nodeptr prevptr = *pList;
if(*pList != NULL && newptr->data.empID < (*pList)->data.empID)
prevptr = *pList;
*pList = (*pList)->link;
prevptr->link = newptr;
newptr->link = *pList;
What happens, when *pList is NULL? In this case prevptr is NULL and
prevptr->link is core dump in the 'else' branch.
[ back to toc ]