I need to copy struct problema1
to struct problema2
, but when doing the way you are in the program below, when I change the struct problema2
, you are also changing the struct problema1
. The way I did it by copying the reference, I wanted to copy without reference, but I do not know how to do it.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
struct Tproblem
{
TList *Lista;
float x;
};
typedef struct Tproblem Problem;
Problem *Problema1 ,*Problema2;
int *x;
Problema1 = new Problem;
Problema1->Lista = new TList;
for( int i = 0 ; i<10; i++)
{
x = new int ;
*x = i;
Problema1->Lista->Add(x) ;
}
Problema2 = new Problem;
Problema2 = Problema1;// aki eu copia a estrutura
for( int i = 0 ; i<Problema1->Lista->Count ;i++)
{
x = (int*)Problema1->Lista->Items[i];
ListBox1->Items->Strings[i]=IntToStr(*x);