请教达人指点
帮我看看这程序 哪里错了 为什么到调用函数那里就不能再执行了呢??????#include"stdio.h"
#include"malloc.h"
#include"string.h"
#define NULL 0
#define STU_TYPE struct student
#define STU_SIZE sizeof(STU_TYPE)
STU_TYPE{
long num;
char name[20];
char sex;
STU_TYPE *next;
};
int n=0;
void main(){
void print(STU_TYPE *);
STU_TYPE *head,*p1,*p2;
p2=p1=(STU_TYPE*)malloc(STU_SIZE);
head=p1;
scanf("%ld%s%s",&p1->num,p1->name,&p1->sex);
while(p1->num!=0)
{
n++;
if(n==1) head=p1;
else
p2->next=p1;
p2=p1;
p1=(STU_TYPE*)malloc(STU_SIZE);
scanf("%ld%s%s",&p1->num,p1->name,&p1->sex);
}
p2->next=NULL;
print(head);
}
void print(STU_TYPE *head)
{
STU_TYPE *q;
q = head;
if (q != NULL)
while (q -> next != NULL)
{
printf("%ld%s%s\n",q->num,q->name,q->sex);
q++;
}
else
printf("void list!");
}