CSDN博客

img ywchen2000

一个简单的恺撒加密程序

发表于2003/5/4 13:57:00  955人阅读

 

#include<iostream>
#include<fstream>
void main(void)

 char strch,ch;
   int i,x;
 ifstream readfile;
 ofstream writefile; 
 readfile.open("1.txt",ios::in | ios::nocreate);  
if(!readfile)  

cerr<<"cannot open thie file for input"<<endl;        
exit(0);    }  
 writefile.open("2.txt",ios::in | ios::nocreate);
 if(!writefile)
 {  
cerr<<"cannot open the file for output"<<endl;  
exit(0);   } 
while(!readfile.eof()) 
{     
ch=readfile.get();      
x=static_cast<int>(ch);   
x=(x+3)%128;
strch=static_cast<char>(x);  
 writefile.put(strch);        
}
}

 

0 0

相关博文

我的热门文章

img
取 消
img