gpt4 book ai didi

C编程,如何递归获取目录和子目录中的文件

转载 作者:太空宇宙 更新时间:2023-11-04 05:07:16 25 4
gpt4 key购买 nike

<分区>

到目前为止,我在堆栈溢出时找到了这个,但这只打印出当前目录而不是子目录。提前致谢!

DIR *dir;
struct dirent *ent;

if ((dir = opendir ("c:\\src\\")) != NULL) {
/* print all the files and directories within directory */
while ((ent = readdir (dir)) != NULL) {
printf ("%s\n", ent->d_name);
}
closedir (dir);
} else {
/* could not open directory */
perror ("");
return EXIT_FAILURE;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com