#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char fileName1[20],fileName2[20];
char temp,buf[200],buf1[200];
int i;
fstream file;
fstream datafile;
cout<<"请输入需要加密的文件名:"<<endl;
cin>>fileName1;
datafile.open(fileName1,ios::in);
if(!datafile)
{
cout<<"打开文件失败!"<<endl;
exit(0);
}
cout<<"第一个文件中的内容是:"<<endl;
while(datafile.eof()==false)
{
datafile.getline(buf,81);
cout<<buf<<endl;
}
cout<<"请输入需要存放加密内容的文件名:"<<endl;
cin>>fileName2;
file.open(fileName2,ios::out);
if(!file)
{
cout<<"打开文件失败!"<<endl;
exit(0);
}
cout<<"加密后的内容是:"<<endl;
datafile.close();
datafile.open(fileName1,ios::in);
while(datafile.eof()==false)
{
datafile.getline(buf1,81);
for(i=0;buf1[i]!='\0';i++)
{
if((buf1[i]!='\n')&&(buf1[i]!=' '))
temp=buf1[i]+2;
else
temp=buf1[i];
file.put(temp);
cout<<temp;
}
}
cout<<endl;
cout<<"已加密!"<<endl;
file.close();
datafile.close();
return 0;
}