c语言函数调用没有参数,这个函数调用没用到参数,那还传参数干什么(3)

当前位置:我的异常网» C语言 » 这个函数调用没用到参数,那还传参数干什么

这个函数调用没用到参数,那还传参数干什么(3)

www.myexceptions.net  网友分享于:2014-04-20  浏览:5次

#include 

#include 

#include "list.h"

/* local function prototype */

static void CopyToNode(Item item, Node * pnode);

/* interface functions   */

/* set the list to empty */

void InitializeList(List * plist)

{

* plist = NULL;

}

/* returns true if list is empty */

bool ListIsEmpty(const List * plist)

{

if (*plist == NULL)

return true;

else

return false;

}

/* returns true if list is full */

bool ListIsFull(const List * plist)  //这个函数比较奇怪,明明参数,函数定义中却没有使用

{

Node * pt;

bool full;

pt = (Node *) malloc(sizeof(Node));

if (pt == NULL)

full = true;

else

full = false;

free(pt);

return full;

}

/* returns number of nodes */

unsigned int ListItemCount(const List * plist)

{

unsigned int count = 0;

Node * pnode = *plist;    /* set to start of list */

while (pnode != NULL)

{

++count;

pnode = pnode->next;  /* set to next node     */

}

return count;

}

/* creates node to hold item and adds it to the end of */

/* the list pointed to by plist (slow implementation)  */

bool AddItem(Item item, List * plist)

{

Node * pnew;

Node * scan = *plist;

pnew = (Node *) malloc(sizeof(Node));

if (pnew == NULL)

return false;     /* quit function on failure  */

CopyToNode(item, pnew);

pnew->next = NULL;

if(scan == NULL)          /* empty list, so place */

*plist = pnew;         /* pnew at head of list */

else

{

while (scan->next != NULL)

scan = scan->next;  /* find end of list    */

scan->next = pnew;      /* add pnew to end     */

}

return true;

}

/* visit each node and execute function pointed to by pfun */

void Traverse  (const List * plist, void (* pfun)(Item item) )

{

Node * pnode = *plist;    /* set to start of list   */

while (pnode != NULL)

{

(*pfun)(pnode->item); /* apply function to item */

pnode = pnode->next;  /* advance to next item   */

}

}

/* free memory allocated by malloc() */

/* set list pointer to NULL          */

void EmptyTheList(List * plist)

{

Node * psave;

while (*plist != NULL)

{

psave = (*plist)->next; /* save address of next node */

free(*plist);           /* free current node         */

*plist = psave;         /* advance to next node      */

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值