当前位置:网站首页>C language recursive folder code
C language recursive folder code
2022-06-12 09:51:00 【Tody Guo】
#include <stdio.h>
#include <io.h>
#include <string.h>
void listall(char *path)
{
_finddata_t fileDir;
long lfDir;
char apath[1024];
sprintf_s(apath, 1024, "%s\\*.*", path);
if ((lfDir = _findfirst(apath, &fileDir)) == -1l)
printf("No file is found\n");
else {
do {
if(fileDir.attrib == _A_SUBDIR && strcmp(fileDir.name, ".")!=0 && strcmp(fileDir.name, "..") != 0){
sprintf_s(apath, 1024, "%s%s\\", path, fileDir.name);
listall(apath);
}else if (strcmp(fileDir.name, ".") != 0 && strcmp(fileDir.name, "..") != 0) {
printf("%s%s\n", path, fileDir.name);
}
} while (_findnext(lfDir, &fileDir) == 0);
}
_findclose(lfDir);
}
int main()
{
char dir[] = "D:\\";
listall(dir);
getchar();
return 0;
}
边栏推荐
- Reading notes of the fifth cultivation
- 六月集训(第12天) —— 链表
- Record and store user video playback history selection
- Thread deadlock and its solution
- Auto.js学习笔记7:js文件调用另一个js文件里的函数和变量,解决调用失败的各种问题
- 科创人·神州数码集团CIO沈旸:最佳实践模式正在失灵,开源加速分布式创新
- Selenium interview question sharing
- UE4_以现成资源探索创建背景场景的方法
- 功能测试面试常见的技术问题,总结好了你不看?
- markdown_图片并排的方案
猜你喜欢
随机推荐
Mycat的使用
UEFI EDKII 编程学习
RecyclerView的onBindViewHolder被同时调用两次解决方法
001:数据湖是什么?
Auto.js学习笔记9:脚本引擎使用,启动指定路径脚本文件和关闭等基础方法
《保护我们的数字遗产:DNA数据存储》白皮书发布
The white paper "protecting our digital heritage: DNA data storage" was released
链式哈希表
Cas d'essai et spécification de description des bogues référence
Automated test learning path, come and learn
005:数据湖与数据仓库的区别
Test case and bug description specification reference
How should the test plan be written? A thought teaches you
Dazzle the "library" action - award solicitation from the golden warehouse of the National People's Congress - high availability failover and recovery of kingbasees cluster
【云原生 | Kubernetes篇】Kubernetes 网络策略(NetworkPolicy)
Financial test interview questions to help you get the offer
IV Transforming regular expressions into finite state automata: DFA minimization
C # getting started series (12) -- string
榜样访谈——董宇航:在俱乐部中收获爱情
gnu-efi开发环境设置






