program received signal sigsegv 链表头结点next赋地址错误

program received signal sigsegv

遇到的现象和发生背景,请写出第一个错

错误如图

img

用代码块功能插入代码,请勿粘贴截图。 不用代码块回答率下降 50%

```c
void create(){
    head1=(struct teacher *)malloc(sizeof(struct teacher));
    head1->next=NULL;
    tail1=head1;
} 

void Tzhuce(){
 //struct teacher*head1
  struct teacher *p1,*p2;
   N1=0;
   p1=p2=(struct teacher *)malloc(sizeof(struct teacher));
   int y=1,n;
   tail1->next=p1;
while(y)
  {

   printf("--------------------\n");
   printf("请输入教师编号:");
   scanf("%d",&p1->num);
   printf("请输入教师名称:");
   scanf("%s",p1->name1);
   p2=p1;
   p1=(struct teacher *)malloc(sizeof(struct teacher));
   p2->next=p1;
   Tnumber++;
   printf("\n1.继续输入.\n0.输入完毕.\n");
   printf("请选择:");
   scanf("%d",&y);
  }
  tail1=p2;
  tail1->next=NULL;
  //while(tail->next!=NULL){
      //tail1=tail1->next;
 // }
 // tail1->next=p3;
  free(p1);
  p1=NULL;
  return;
  //goto Tagin;
  //while(y==1);
  //printf("提示:输入完毕!你一共输入%d个\n",n);
}