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

来源:互联网 发布:如何仿真网络性能测试 编辑:程序博客网 时间:2024/04/29 22:32

       按行加密的前提是按行读取,下面实现按行读取(请注意:你很可能运行不了下面的程序,因为我估计你没有安装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;        }    }}//---------------------------------------------------------------------------

      经测试,上面的程序正确。加密其实就是变换,无需多说。

原创粉丝点击