【发布时间】:2013-05-26 22:52:55
【问题描述】:
typedef struct slist *LInt;
typedef struct slist{
int value;
LInt next;
}Node;
void reverse(LInt *l){
LInt tail;
if(*l){
tail=(*l)->next;
reverse(&tail);
snoc(&tail,(*l)->value);
free(*l),
*l=tail;
}
}
在 main 上,我这样调用函数:reverse(&l); (l 是“LInt l”),snoc 所做的是将值放在列表的最后一个链接。
我的问题是,为什么我们在调用函数时必须传递“l”的地址?为什么在反向的标题上,有“LInt *l”?它是指向我传递的地址的指针吗?
如果这是一个愚蠢的问题,如果我犯了任何语法错误(英语不是我的母语),我很抱歉。
提前谢谢你。
【问题讨论】:
-
开启警告。
reverse接受LInt并且您将其传递给LInt*。不一样。
标签: c list pointers linked-list malloc