加密过程
#include<stdio.h>
#pragma warning(disable:4996)
int main(void)
{
FILE * fp1 = fopen("D:\\a.txt", "r");
FILE * fp2 = fopen("D:\\b.txt", "w");
if (!fp1)
{
printf("文件打开失败");
return -1;
}
char ch;
while ((ch = fgetc(fp1)) != EOF)
{
ch++;
fputc(ch, fp2);
}
fclose(fp1);
fclose(fp2);
return 0;
}
我的a.txt里面的文本是:玄幻小说
这是解密过程
#include<stdio.h>
#pragma warning(disable:4996)
int main(void)
{
FILE * fp2 = fopen("D:\\b.txt", "r");
FILE * fp3 = fopen("D:\\c.txt", "w");
if (!fp2)
{
printf("文件打开失败");
return -1;
}
char ch;
while ((ch = fgetc(fp2)) != EOF)
{
ch--;
fputc(ch, fp3);
}
fclose(fp2);
fclose(fp3);
return 0;
}
为什么在c.txt中输出的是:? ,输出其他东西都好使,就玄幻小说这四个字输出的是问号。