一直显示读访问权限冲突,不知道是为什么
#include
#include
#include
typedef struct node {
int data;
struct node* next;
}node, * Linklist;
void creatList_1(node* l, int n) {//头插法
node* p;
int i,j;
p = NULL;
l = (Linklist)malloc(sizeof(node));
l->next = NULL;
for (i = n;i > 0;--i) {
p = (Linklist)malloc(sizeof(node));
scanf_s("%d", &j);
p->data = j;
p->next = l->next;
l->next = p;
}
}
void PrintList(node* l) {
printf("内容为:");
while (l->next != NULL)
{
printf("%d ", l->next->data);
l = l->next;
}
printf("\n");
}
void main() {
Linklist La;
La = (node*)malloc(sizeof(node));//动态分配内存
creatList_1(La, 7);//头插法,倒序
PrintList(La);
}
12行删掉啊