scandir Tripe指针参数,通过地址传递给双指针

问题描述

在使用scandir函数时,documentation指定以下行:

int scandir(const char *dirp,struct dirent ***namelist,...);

因此,按照说明进行了以下操作:

stuct dirent ***foo;
...
...
int test = scandir("foo",foo,...);

但是它不能编译。这是一个错误。查看文档中更深处的示例,我应该像下面这样调用scandir

struct dirent **namelist;
int n;
n = scandir(".",&namelist,NULL,alphasort);

我不明白为什么应该将三指针参数与地址一起传递给两个指针结构。太出乎意料了,如果没有提供的示例,我认为我自己也无法解决。是错字还是我想念东西?

我的代码在工作,所以我只想问一下语法,我已经读过documentation about C pointer

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)