链表能输入不能输出,应该如何修改才能输出?

#include"stdio.h"
#include"malloc.h"
#define LEN sizeof(struct n)
struct n
{
    long num;
    struct n next;
};
 
void main()
{  int n,i;
  scanf("%d",&n);
  struct n*head ,*p1,*p2,*p;
  p1=p2=(struct n
)malloc(LEN);
  scanf("%ld",&p1->num);
  for(i=0;i   {  if(i==0)  head=p1;
else p2->next=p1; 
p2=p1;
    p1=(struct student*)malloc(LEN);
    scanf("%ld",&p1->num);
    p1=p2;
  }
  p2->next=NULL;
  p=head;
  while(p!=NULL)
  {
    printf("%ld",p->num);
    p=p->next;
  }
}
 


struct n
{
    long num;
    struct n next;
        //改成
        struct n* next;
};
p1=p2=(struct n)malloc(LEN);修改为p1=p2=(struct n*)malloc(LEN);

 for(i=0;i   {  if(i==0)  head=p1;修改为 for(i=0;i <num1;i++)  {  if(i==0)  head=p1;

 struct n
{
    long num;
    struct n* next;
};