如何在txt文件中中删除指定字符 在线等 急~~~~~~~~~~~~ 20
我想要完整的源程序C++的voiddele(char*in_name,char*out_name){FILE*fp1,*fp2;charc[1024];chars[102...
我想要完整的源程序 C++的
void dele(char*in_name,char *out_name)
{
FILE *fp1,*fp2;
char c[1024];
char s[1024];
int len,i;
fp1=fopen(in_name,"r");
if(fp1==NULL)
{
printf("cannot open in-name.\n");
exit(1);
}
fp2=fopen(out_name,"w");
if(fp2==NULL)
{
printf("cannot open or create out-name.\n");
exit(1);
}
printf("请输入你要删除的字符串\n");
scanf("%s",s);
while(fgets(c,1024,fp1)!=NULL)
{
len=strlen(c);
if (c[len-1]=='\n')
{
c[len-1]='\0';
len--;
}
while (c[len-1]!='\n')
{
c[len]=fgetc(fp1);
if (c[len]==EOF)
break;
len++;
}
c[len]='\0';
接着这里怎么写啊
fclose(fp1);
fclose(fp2);
}
} 展开
void dele(char*in_name,char *out_name)
{
FILE *fp1,*fp2;
char c[1024];
char s[1024];
int len,i;
fp1=fopen(in_name,"r");
if(fp1==NULL)
{
printf("cannot open in-name.\n");
exit(1);
}
fp2=fopen(out_name,"w");
if(fp2==NULL)
{
printf("cannot open or create out-name.\n");
exit(1);
}
printf("请输入你要删除的字符串\n");
scanf("%s",s);
while(fgets(c,1024,fp1)!=NULL)
{
len=strlen(c);
if (c[len-1]=='\n')
{
c[len-1]='\0';
len--;
}
while (c[len-1]!='\n')
{
c[len]=fgetc(fp1);
if (c[len]==EOF)
break;
len++;
}
c[len]='\0';
接着这里怎么写啊
fclose(fp1);
fclose(fp2);
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询