c++学习log1

最近开始重学c++,

也是第一次博客  暂且来试试水吧

首先打算用c++写个简单的文档加密算法(当然只是初级的,能够读取txt文本然后简单加密解密一下就行了

--------------------------------------------------------------------------------------------------------------------------------------------

#include<windows.h>
#include<fstream.h>
void encryption(char *c,int n);//加密
void deciphering(char *,int );//解密
int main()
{
char buff2[100];
fstream wf("c:\\local.txt",ios::out|ios::in);
streampos po=wf.tellg();
wf.seekg(0);
cout<<' ';
while(wf.eof())
{
po=wf.tellg();
wf.getline(buff2,100);
cout<<buff2<<endl;
deciphering(buff2,100);
cout<<buff2<<endl;
wf.seekg(po);
wf << buff2<<"\n";//即使是写入也会使指针后移一行
}
return 0;
}
void encryption(char *c ,int n )
{
int max=strlen(c);
for(int i=0;i<max;i++)
{
c[i]+='王';
}
}
void deciphering(char *c ,int n)
{
int max=strlen(c);
for(int i=0;i<max;i++)
{
c[i]-='王';
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值