代码如下 :
#include
int main()
{
char ch1, ch2;
scanf("%c", &ch1);
// 打开文件 A.txt
FILE *pf1 = fopen("d:\\A.txt", "r+");
// 打开文件 B.txt
FILE *pf2 = fopen("d:\\B.txt", "w");
while (!feof(pf1)) {
ch2 = fgetc(pf1);
if (ch2 != ch1) {
fputc(ch2, pf2);
}
}
// 关闭文件
fclose(pf1);
fclose(pf2);
return 0;
}
运行结果: