求解,这个程序那个地方错了???
#include<stdio.h>#include<stdlib.h>
struct temp{
int data;
struct temp *next;
};
int main()
{
int i;
struct temp *p=NULL,*head=NULL,*pt=NULL;
for(i=0;i<5;i++)
{
p=(struct temp *)malloc(sizeof(struct temp));
if(p==NULL) { printf("wrong");
break;
}
printf("enter a number:\n");
scanf("%d",&p->data );
if(i==1) head=p;
pt->next =p;
pt=pt->next ;
pt->next =NULL;
}
printf("these numbers:") ;
p=head;
while(p)
{
printf("%d",p->data );
p=p->next ;
}
return 0;
}