- 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");}
------解决方案--------------------