您的位置:首页 > 其它

在BCB中将文本文件按行(不考虑空行)加密

2013-10-07 23:38 381 查看
       按行加密的前提是按行读取,下面实现按行读取(请注意:你很可能运行不了下面的程序,因为我估计你没有安装BCB):

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include <fstream>
#include <string>
#include <iostream>
using namespace std;

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
ifstream in("computer.cfg");
ofstream out("another.cfg");
string filename;
string line;

while (getline (in, line))
{
if("" != line)
{
out << line << endl;
}
}
}
//---------------------------------------------------------------------------

      经测试,上面的程序正确。加密其实就是变换,无需多说。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: