Дастур коди
#include
#include
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void AnsiStringToCharPointer(char * c, AnsiString s, int n = 0)
{
int k = s.Length();
if(k > n && n != 0){ k = n; }
for(int i = 0; i < k; i++)
{
c[i] = s[i+1];
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
OpenDialog1->Execute();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
SaveDialog1->Execute();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::OpenDialog1CanClose(TObject *Sender,
bool &CanClose)
{
AnsiString name = OpenDialog1->FileName;
char c[100] = "";
AnsiStringToCharPointer(c,name);
ifstream in(c);
Memo1->Text = "";
while(in.good())
{
in.getline(c,100);
Memo1->Lines->Add(c);
}
in.close();
}
//---------------------------------------------------------------------------
Do'stlaringiz bilan baham: |