修改如下,供参考:
#include <stdio.h>
#include <malloc.h>
struct LNode {
int data;
struct LNode* next;
};
void Initlist(struct LNode** list)
{
(*list) = (struct LNode*)malloc(sizeof(struct LNode));
(*list)->next = NULL;
}
int main()
{
struct LNode* list;
Initlist(&list);
}
你还没给它分配内存,就把它当做参数传进去了,传参需要传它的地址的