current position:Home>C language file encryption applet problem

C language file encryption applet problem

2022-02-02 16:22:54 CSDN Q & A

#include "stdio.h"
int main()
{
FILE *fp,*fp1;
if((fp=fopen("e:\abc.txt","r"))==NULL)// I created this in advance
{
printf("Cannot open the file\n");
getchar();
return 1;
}
if((fp1=fopen("e:\bcd.txt","w+"))==NULL)
{
printf("Cannot find the file\n");
getchar();
return 1;
}
char ch;
ch=fgetc(fp);
while(ch!=EOF)
{
putchar(ch);
fputc(ch+1,fp1);
ch=fgetc(fp);
}
putchar('\n');
rewind(fp1);
ch=fgetc(fp1);
while(ch!=EOF)
{
putchar(ch);
ch=fgetc(fp1);
}
putchar('\n');
fclose(fp);
fclose(fp1);
return 0;
}

img


Why are there several more boxes in the back , solve




Refer to the answer 1:

abc.txt At the end of the file , Are there some spaces ?




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202021622527406.html

Random recommended