#include <stdio.h>
#include <string.h>
#include <cstdlib>
const int KEY=118;
int main()
{
FILE* hOFile = fopen("file1","w");
FILE* hIFile;
char sign;
for(int i=254; i>=0; i--)
fprintf(hOFile,"%c",i);
fclose(hOFile);
hIFile = fopen("file1","r");
hOFile = fopen("file2","w");
for(int i=254; i>=0; i--)
{
fscanf(hIFile,"%c",&sign);
fprintf(hOFile,"%c",(sign^KEY));
}
fclose(hIFile);
fclose(hOFile);
hIFile=fopen("file2","r");
hOFile=fopen("file3","w");
for(int i=254; i>=0; i--)
{
fscanf(hIFile,"%c",&sign);
fprintf(hOFile,"%c",(sign^KEY));
}
fclose(hIFile);
fclose(hOFile);
}
我的意思是 file3 与 file1 相同。不幸的是,file3 在 ASCII KEY-9 字符后崩溃。具体来说,对于这个例子:
文件1:
ţ令÷ÖTOVORITIOMITAULIS „‚€~}|{zyxwvutsrqponmlkjihgfedcba`_^][ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!
文件3:
ţ令÷ÖTOVORITIOMITAULIS „‚€~}|{zyxwvutsrqponmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm