khafan khafan - 27 days ago 12
C++ Question

C++ to Delphi pointer conversion

I am trying to convert an open source C++ project to Delphi(Berlin 10.1). it uses some pointers which i can not find a way to convert them to Delphi pointers. How can i translate this piece code from C++ to Delphi?
Here is the code:

double* ptr;

ptr = (double*)malloc(10*sizeof(double)+324);



ptr[10*n+1]=y*12;

ptr[1]=(double)n;

int n;

double** Solution;

*Solution = ptr;

MBo MBo
Answer
type
   TDoubleArray  = array[Word] of Double;
   PDoubleArray  = ^TDoubleArray;


ptr: PDoubleArray;

GetMem(ptr, 10*sizeof(double)+324);


ptr[10*n+1] := y*12;   

ptr[1] := n;

//here you have to check usage case
//probably you need 2D array
Solution: ^PDoubleArray;

Solution^ := ptr;