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

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

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

#include 
#pragma hdrstop

#include 
#include 
#include 
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;
        }
    }
}
//---------------------------------------------------------------------------

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

你可能感兴趣的:(S1:,BCB)