#include <stdio.h>
#include <stdlib.h>
void filename(void);
void delname(void);
void rename(void)
{
FILE *indexfile=fopen("filename.txt","r");
FILE *inputfile,*outputfile;
char filepath[100]="\0";
char outfilepath[100]="\0";
int i=0;
int j=0;
char ch;
while((ch=fgetc(indexfile))!=EOF)
{
if(ch!='\n')
{
filepath[i++]=ch;
if(ch!=')'&&ch!='(') outfilepath[j++]=ch;
}
else if(filepath[i-1]!='e'&&filepath[i-1]!='t'&&i!=0)
{
filepath[i]='\0';
outfilepath[j]='\0';
inputfile=fopen(filepath,"rb");
outputfile=fopen(outfilepath,"wb");
while(!feof(inputfile)) fputc(fgetc(inputfile),outputfile);
fclose(inputfile);
fclose(outputfile);
i=0;j=0;
}
else
{
i=0;j=0;
}
}
}
int main(void){
int i = 0;
char oldname[45];
char newname[45];
// FILE * fp;
filename();
rename();
//rename函数时遇到 点问题
//这怎么写好?
getchar();
delname();
// fclose(fp);
return 0;
}
void filename(void){
system("dir /b > filename.txt");
}
void delname(void){
if (remove("filename.txt")==0)
;
else
puts("no");
}
#include <stdlib.h>
void filename(void);
void delname(void);
void rename(void)
{
FILE *indexfile=fopen("filename.txt","r");
FILE *inputfile,*outputfile;
char filepath[100]="\0";
char outfilepath[100]="\0";
int i=0;
int j=0;
char ch;
while((ch=fgetc(indexfile))!=EOF)
{
if(ch!='\n')
{
filepath[i++]=ch;
if(ch!=')'&&ch!='(') outfilepath[j++]=ch;
}
else if(filepath[i-1]!='e'&&filepath[i-1]!='t'&&i!=0)
{
filepath[i]='\0';
outfilepath[j]='\0';
inputfile=fopen(filepath,"rb");
outputfile=fopen(outfilepath,"wb");
while(!feof(inputfile)) fputc(fgetc(inputfile),outputfile);
fclose(inputfile);
fclose(outputfile);
i=0;j=0;
}
else
{
i=0;j=0;
}
}
}
int main(void){
int i = 0;
char oldname[45];
char newname[45];
// FILE * fp;
filename();
rename();
//rename函数时遇到 点问题
//这怎么写好?
getchar();
delname();
// fclose(fp);
return 0;
}
void filename(void){
system("dir /b > filename.txt");
}
void delname(void){
if (remove("filename.txt")==0)
;
else
puts("no");
}