标题:有关单链表的销毁操作,有点问题,求帮助?
取消只看楼主
zc1992312
Rank: 2
等 级:论坛游民
帖 子:43
专家分:12
注 册:2013-3-20
结帖率:57.14%
已结贴  问题点数:20 回复次数:1 
有关单链表的销毁操作,有点问题,求帮助?
#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已停止工作
搜索更多相关主题的帖子: include 
2013-10-11 23:06
zc1992312
Rank: 2
等 级:论坛游民
帖 子:43
专家分:12
注 册:2013-3-20
得分:0 
回复 2楼 木头心
Ploynomial pList   就相当于 LNode * pList吧!!
  那你在给pList 前面加个&  是不是双重指针了  ?
2013-10-11 23:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-421752-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.200511 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved