看看这段代码运行时为什么有未知错误?

#include<stdio.h> #include<stdlib.h> typedef int DataType; typedef struct node { DataType data; struct node *next; }student; typedef student linklist; linklist createlist() { linklist head,rear; student p; int m=1; head=rear=NULL; while(m) { p=(linklist)malloc(sizeof(student)); scanf("%d",&p->data); if(head==NULL) { head->next=p; } else { rear->next=p; } rear=p; } rear->next=NULL; return p; } void printlist(linklist head) { while(head!=NULL) { printf("%d ",head->data); head=head->next; } }

int main() { printlist(createlist()); return 0;

}

typedef student *linklist;

8