OK, there's a bug here:
The problem is that P is only assigned a value if (units[low]->IDs == NULL). If that condition is not true, P does not get assigned.
void add_student(int loopnum)
int low, student_ID;
scanf("%d %s", &student_ID, unit_name);
units[loopnum] = (unit_struct*) malloc(sizeof(unit_struct));
units[loopnum]->name = malloc(sizeof(unit_name)+1);
while(strcmp(units[low]->name, unit_name) !=0)
if(units[low]->IDs == NULL)
units[low]->IDs = MakeEmpty(NULL);
P = Header(units[low]->IDs);
printf ("AddStud: pointer P pointing to: %p\n", P);
P = Advance(P);
In either case, you use P in the call : P = Advance(P); which is wrong!
I put a printf statement in to display the contents of the pointer to prove it:
Also, the Advance function does nothing for this variable as it's local to the add_student function. I'm not sure what you're trying to do with it.
AddStud: pointer P pointing to: 0x970c10
AddStud: pointer P pointing to: 0x0
Segmentation fault (core dumped)
Have fun fixing......