有关单链表的销毁操作,有点问题,求帮助?
#include <stdio.h>#include <stdlib.h>
#define TURE 1
#define FALSE 0
#define Max 20
typedef struct
{
float coef; /*系数*/
int expn; /*指数*/
}ElemType;
typedef struct LNode
{
ElemType data;
struct LNode *pNext;
}LNode, *Ploynomial;
int InitList(Ploynomial pList)
{
pList = (Ploynomial ) malloc (sizeof (LNode)); /*创造头节点*/
pList -> pNext = NULL;
pList -> data.coef = 0.0;
pList -> data.expn = 0;
return TURE;
}
int DestroyList(Ploynomial pList)
{
Ploynomial p = pList, q = p -> pNext;
while (q != NULL)
{
free(p);
p = q;
q = p -> pNext;
}
free(p);
return TURE;
}
main()
{
Ploynomial List;
printf ("...\n");
InitList(List);
DestroyList(List);
system ("pause");
}
运行结构。。
多项式运行环境.exe已停止工作