[英]Decoding a file
#include <Windows.h>
#include <cstdio>
const int KEY=111;
void encryptStrA(char* sometext)
{
int length;
length=strlen(sometext);
for(int i=0; i<length;i++)
sometext[i]^=KEY;
}
int main(void)
{
FILE* pFile=fopen("pliczek","wb");
char sign;
char sampleString[]="Hello world!";
encryptStrA(sampleString);
fprintf(pFile,"%c%c%s%c%c",13^KEY,10^KEY,sampleString,13^KEY,10^KEY);
fclose(pFile);
pFile=fopen("pliczek","rb");
while(!feof(pFile))
{
fscanf(pFile,"%c",&sign);
printf("%c",sign^KEY);
}
fclose(pFile);
system("PAUSE");
return 0;
}
I evaded some tricky things 我回避了一些棘手的事情
In spite of these, it still has been outputting "Hell" instead of "Hello World!"? 尽管如此,它仍然输出“地狱”而不是“Hello World!”? More precisely, cuts everything after spotting the key character .What's the reason?
更确切地说,在发现关键人物后削减一切。这是什么原因? I use OS in which every line of text is ended with carriage return(ASCII 13) and line feed (10).
我使用OS,其中每行文本都以回车符(ASCII 13)和换行符(10)结束。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.