首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > PB >

遍历目录遇到的有关问题

2012-05-12 
遍历目录遇到的问题。C/C++ codestringList(const char *path){struct dirent* ent NULLDIR *p_dirp_di

遍历目录遇到的问题。

C/C++ code
string  List(const char *path){  struct dirent* ent = NULL;  DIR *p_dir;  p_dir = opendir(path);  if(p_dir == NULL)    {      return 0;    }  while (NULL != (ent = readdir(p_dir)))    {      //我如何知道p_dir中有哪些子目录?      //假如p_dir中有三个子目录  a,b,c,我如何进入子目录?    }}int main(){   List("/home/yxz");}    


[解决办法]
探讨
引用:

system("dir /b /a-d c:\\*.* >d:\\allfiles.txt");
//读文件d:\\allfiles.txt的内容即C:\\下所有文件的名字
system("dir /b /ad c:\\*.* >d:\\alldirs.txt");
//读文件d:\\alldirs.txt的内容即C:\\下所有子目录的名字
请记住,能用she……

热点排行