基本上我想要一个链表数组,每个链表都有自己的标题。这是我的代码:
struct node{
int location;
struct node *next;
struct node *previous;
};
typedef struct ListHeader{
nodeType *first;
nodeType *current;
nodeType *last;
} ListHeader;
struct adjList{
ListHeader *header;
int size;
};
struct List{
adjListType *list;
int size;
};
ListType newList(int numVerts){
ListType new = malloc(sizeof(struct List));
new->list = calloc(numVerts, sizeof(adjListType));
new->size = numVerts;
int i;
for(i = 0; i <= numVerts; i++){
new->list[i] = newAdjList();
}
return new;
}
adjListType newAdjList(void){
adjListType new = malloc(sizeof(struct adjList));
new->header = malloc(sizeof(ListHeader));
new->header->first = NULL;
new->header->current = NULL;
new->header->last = NULL;
new->size = 0;
return new;
}
nodeType newNode(int location){
nodeType new = malloc(sizeof(struct node));
new->location = location;
return new;
}
当我尝试使用此代码(ListType l,int location)移动到链表中的下一个节点时,它给了我一个错误
l->list[location]->header->current = l->list[location]->header->current->next;
这是我得到的错误:
成员引用基类型“nodeType”(又名“struct node*”)不是结构或联合