c程序调试问题
高手帮忙调试一下,谢谢#include "stdio.h"
#include "malloc.h"
#define LEN sizeof(struct list)
struct list
{
int num;
struct list *next;
};
struct list *creat()
{ struct list *head;
struct list *p1,*p2;
int n=0;
p1=p2=(struct list *)malloc(LEN);
scanf("%d",p1->num);
head=NULL;
while(p1->num!=0)
{
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct list *)malloc(LEN);
scanf("%d",p1->num);
p2->next=NULL;
return(head);
}
}
void main()
{
struct list *p;
p=creat();
while(p!=NULL)
{
printf("%d\n",p->num);
p=p->next;
}
}