文件移位加密与解密(1人)
要求实现
1)文件加密;
2)文件解密。
备注:将某一已知文件的内容(仅限于英文字母)以字符形式读出,根据密钥(用户从键盘输入)将对应字符进行移位操作即可,解密时移动相反。
例如:加密:设原文为abcdef,密钥为5,则有abcdef每个字母按字母表向后移动5们(注:z后接a)可得到密文(乱码)fghijkl;对该文件解密:文件内容为fghijk1,密钥为5,则有fghijk1每个字母向前移动5位(注a后接z),可得到原文abcdef。
运行不了,编译出错
追答//注意此行代码
//FILE *fp=fopen("test.txt","r");//自行选择文本文件
//在.cpp文件相同目录下新建文件test.txt
//------------------test.txt 文件实例-------------------//
The Impact of Electronic Products on Family Reunion。The picture depicts an authentic scene of family get-together. Everyone sits around the dinner table for the family reunion; however, oddly, both children and young adults immerse themselves in electronic products like iPhones or iPads, leaving their old parents looking at each other speechlessly.
//------------------test.txt 文件实例-------------------//
第35行出错,不知道为什么。第25行的是text吗?后面都是用的text,但你写成test
追答把你的有错误代码发个我
追问for(int i=0;i<strlen(text)+1; i++)
for(int i=0;i<strlen(text)+1; i++)
分别是36和53行的
先尝试压缩包源码:http://pan.baidu.com/s/1bnppVxP
//两处可更改为:
int size =strlen(text)+1;
for(int i=0; i<size ; i++)
这是什么原因呢?
可以了
谢谢
有没有简单一点的?有的话我再问一次,再采纳你。