Лаборатория иши №13 Мавзу: 13. C++da matnli fayllar bilan ishlash


Download 174.14 Kb.
bet4/5
Sana29.08.2023
Hajmi174.14 Kb.
#1671259
1   2   3   4   5
Bog'liq
13 Лаборатория иши

Дастур коди


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

Download 174.14 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling