有一道C语言的题,大家来帮忙看看,谢谢!!!

编写递归函数,实现删除目录结构的功能,并在主函数中进行调用。(提示:本题所需要使用的函数有:_findfirst、_findnext、_findclose、remove、_rmdir,以上函数分别包含在io.h、direct.h中。)请用归纳推理的方法来分析、设计算法并设计程序。
哪位高手帮我提供个思路,最好是有代码,谢谢。

解题思路是,在百度搜索一下,关键字 c语言 删除目录 递归

void RemoveNullDir(char DirName[MAXDIR])
{
int p;
struct ffblk ff;
char StrTemp[MAXDIR];
strcpy(StrTemp,DirName);
strcat(StrTemp,"\\*.*");
p=findfirst(StrTemp,&ff,0);
while(!p)
{
strcpy(StrTemp,DirName);
strcat(StrTemp,"\\");
strcat(StrTemp,ff.ff_name);
if(((ff.ff_attrib&0xf0)==16||(ff.ff_attrib&0xf0)==48)&&strcmp(ff.ff_name,".")&&strcmp(ff.ff_name,".."))
//如是子目录(不包括.和..子目录)
{
RemoveNullDir(StrTemp); //调用递归函数
}
p=findnext(&ff);//继续查找匹配文件
}//结束while
rmdir(DirName);
}

参考资料:http://topic.csdn.net/t/20010331/20/90988.html

温馨提示:内容为网友见解,仅供参考
第1个回答  2006-12-13
使用C语言遍历某一目录下所有的文件
struct ffblk file;
int flag;
flag=findfirst("*.*",&file,attribute);
while(flag==0)
{
printf("%s\n",file.ff_name);
flag=findnext(&file);
}
相似回答