#include <iostream>
#include <fstream>
using namespace std;
int main(){
ifstream iFile("MySong.txt");
//get the length of the file
iFile.seekg(0,ios::end);
int nFileLen = iFile.tellg();
iFile.seekg(0,ios::beg);
//allocate memory
char* str = new char[nFileLen+1];
//read data as block
iFile.read(str,nFileLen);//读取nFileLen个字节的数据并存储到str变量
iFile.close();
str[nFileLen]=0;
int nCaesar = 3;//假设Caesar移位为3
int n=0;//记录回车数目
for(int i=0;i< nFileLen;i++){
//不做任何处理,直接输出字符,看是否出现\r\n
printf("%c",str[i]);
//开始对字母进行加密,如果位移后大于'z'或'Z',则减去26
if((str[i] > 'a') && (str[i] < 'z')){
str[i] += nCaesar;
if(str[i] > 'z'){
str[i] -= 26;
}
}else if((str[i] > 'A') && (str[i] < 'Z')){
str[i] += nCaesar;
if(str[i] > 'Z'){
str[i] -= 26;
}
}
}
ofstream oFile("mySong2.txt");
oFile.write(str,nFileLen);
oFile.close();
delete[] str;
return 0;
}