Witam
Zapisałem dane do pliku, następnie chce je wczytać wg. poniższego kodu. Wszystko jest ok, tylko się zastanawiam czy jest możliwe zrobić pętle. Kombinuje metodą prób i błędów i nic. Cały czas mnie zastanawiają te Edit1, Edit2 itd. Czy jest to możliwe?
void __fastcall TForm2::Otwrz1Click(TObject *Sender)
{
if(OpenDialog1->Execute())
{
char *Buf1 = new char[255];
char *Buf2 = new char[255];
char *Buf3 = new char[255];
char *Buf4 = new char[255];
char *Buf5 = new char[255];
char *Buf6 = new char[255];
char *Buf7 = new char[255];
char *Buf8 = new char[255];
char *Buf9 = new char[255];
char *Buf10 = new char[255];
char *Buf11 = new char[255];
char *Buf12 = new char[255];
char *Buf13 = new char[255];
char *Buf14 = new char[255];
char *Buf15 = new char[255];
char *Buf16 = new char[255];
ifstream infile;
infile.open(OpenDialog1->FileName.c_str());
//infile.getline(Buf, 255);
infile >> Buf1;
infile >> Buf2;
infile >> Buf3;
infile >> Buf4;
infile >> Buf5;
infile >> Buf6;
infile >> Buf7;
infile >> Buf8;
infile >> Buf9;
infile >> Buf10;
infile >> Buf11;
infile >> Buf12;
infile >> Buf13;
infile >> Buf14;
infile >> Buf15;
infile >> Buf16;
/*for(int i = 0; i < 15; i++)
{
infile.getline(Buf, 255);
Memo1->Lines->Add((AnsiString)Buf);
} */
infile.close();
//Edit1->Add((AnsiString)Buf);
Edit1->Text = Buf1;
Edit2->Text = Buf2;
Edit3->Text = Buf3;
Edit4->Text = Buf4;
Edit5->Text = Buf5;
Edit6->Text = Buf6;
Edit7->Text = Buf7;
Edit8->Text = Buf8;
Edit9->Text = Buf9;
Edit10->Text = Buf10;
Edit11->Text = Buf11;
Edit12->Text = Buf12;
Edit13->Text = Buf13;
Edit14->Text = Buf14;
Edit21->Text = Buf15;
Edit15->Text = Buf16;
delete Buf1, Buf2, Buf3, Buf4, Buf5, Buf6, Buf7, Buf8;
delete Buf9, Buf10, Buf11, Buf12, Buf13, Buf14, Buf15, Buf16;
}
}
Dzięki za ew. podpowiedź