请教哪个函数可以活得目录下文件的数目

请问哪个函数可以活得目录下文件的数目?
linux下的。。。

谢谢


scandir


#include <stdlib.h> ;
#include <stdio.h> ;
#include <sys/types.h> ;
#include <dirent.h> ;

int ListDir(char *pcPath)
{
DIR *pDir;
struct dirent *pDirent;

if((pDir = opendir(pcPath)) == NULL)
{
closedir(pDir);
return -1;
}

while((pDirent = readdir(pDir)) != NULL)
{
printf( "%s\n ", pDirent-> ;d_name);
}
closedir(pDir);

return 1;
}

int main(void)
{
ListDir( "/home ");
return 1;
}


ls |wc -l

请教哪个函数可以活得目录下文件的数目

相关文章:

你感兴趣的文章:

标签云: