⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xdel.c

📁 压缩包内有使用C语言编写的各种数学算法的源代码。
💻 C
字号:
#include <stdio.h>
#include <alloc.h>
#include <dir.h>
#include <string.h>
#include <io.h>
#include <conio.h>
#include <process.h>
#include <ctype.h>

main(int argc,char *argv[])
{
 char presname[MAXPATH];
 int problem;
 if(argc>1)
	{
	strcpy(presname,argv[1]);
	}
 else
	{
	printf("Usage: redir [dirname newname]\n");
	exit(1);
	}
 problem=deldir(presname);
 if(!problem)
	printf("\n very good!");
 else printf("\n too bad I failed!");
 }

int deldir(char presname[])
{
 int delfiles(char *);
 char searchstr[MAXPATH];

 if(!chdir(presname)) /*exist this dir*/
	{
	strcpy(searchstr,"*.*");
	if(!delfiles(searchstr))
		{
		printf("\nfail to del all files");
		return 1;
		}
	chdir("..");
	if(rmdir(presname))
		{
		printf("\nfaile to remove  this dir\n");
		return 1;
		}
	else 
		{
		printf("\nsuccess to remove  this dir\n");
		return 0;
		}
	}
 return 0;
}

int delfiles(char searchstr[])
{
 int done;
 struct ffblk dta;
 char oldname[MAXPATH],drive[MAXPATH],subdir[MAXPATH],
      pathname[MAXPATH],file[MAXFILE],ext[MAXEXT];

 fnsplit(searchstr,drive,subdir,file,ext);
 sprintf(pathname,"%s%s",drive,subdir);

 done=findfirst(searchstr,&dta,47);
 while(!done)
	{
	strcpy(oldname,pathname);
	strcat(oldname,dta.ff_name);
	strupr(oldname);
	if(unlink(oldname))
		{
		printf("\nfail to unlink %s\n",oldname);
		return 0;
		}
	done=findnext(&dta);
	}
 return(1);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -