0
我想写一个列表中的列表程序。 于是就有了list.h文件:取消引用“void *”指针 - 列表中的列表
typedef struct node {
void *ptr;
struct node *next;
struct node *prev;
} NODE;
typedef struct list {
struct node *head;
struct node *tail;
int size;
char name[MAX_SIZE_NAME];
} LIST;
起初我有列表,例如list_。 现在我分配5个元素。
并在每个节点我想分配一个新的列表。 我tryed与此代码:
if (list_->head->next == list_->tail) {
list_ins_next(list_);
ptr = list_->tail->prev;
ptr->ptr = malloc(sizeof(LIST));
ptr->ptr->head = malloc(sizeof(NODE));
对不起我没有那么多的编程经验,但是这将是巨大的,如果你能帮我
的错误:提领“无效*”指针
什么是代表'节点:: ptr'?它是否总是指向包含'struct list'或是一个任意的数据存储? – Dai
另外,如果你使用'void *',你可能做错了什么(因为你放弃了类型安全)。 – Dai