这个线性表的建立的程序为什么在 vc 下没有编译错误但运行不了?
#include <stdio.h>#include <stdlib.h>
typedef struct _NodeList
{
int m_data;
_NodeList* m_next;
}NodeList;
NodeList * createList()
{
NodeList *head,*temp,*tail;
head=tail=NULL;
for (int i = 0; i < 10; i++)
{
temp=(NodeList *)malloc(sizeof(NodeList));
scanf("%d",&temp->m_data);
temp->m_next = NULL;
if(head==NULL)
{
head = tail = temp;
}
else
{
tail->m_next = temp;
tail = temp;
}
}
return head;
}