STUDENT *create_empty_list()
{
STUDENT *p_new_list;
if((p_new_list = (STUDENT*) malloc(sizeof(STUDENT))) == NULL)
{
printf("\nError #%d in create_empty_list.", HEADER_ALLOC_ERROR);
exit(HEADER_ALLOC_ERROR);
}
p_new_list->id_number = LIST_HEADER;
if((p_new_list->p_next_student = (STUDENT*) malloc(sizeof(STUDENT))) == NULL)
{
printf("\nError #%d in create_empty_list.", TRAILER_ALLOC_ERROR);
exit(TRAILER_ALLOC_ERROR);
}
p_new_list->p_next_student->p_next_student = LIST_TRAILER;
p_new_list->p_next_student->p_next_student = NULL;
return p_new_list;
}
我不确定如何将头和尾正确地连接到节点上。