用*Init_LNode()函数创建新单链表时,(r->next=p; )这行出现SIGSEGV segmentation fault 问题。并不觉得哪里非法占用内存啊
struct LNode *Init_LNode()
{
struct LNode *head=NULL,*r=NULL,*p=NULL;
int data;
r=head;
printf("Input 数组数:");
scanf("%d",&data);
while(data!=0){
p=(struct LNode*)malloc(sizeof(struct LNode));
if(!p)exit(0);
p->data=data;
r->next=p; <-SIGSEGV segmentation fault
r=p;
scanf("%d",&data);
}
r->next=NULL;
return head;
}
r=head复制的是 null,无法r->next