Link to home
Start Free TrialLog in
Avatar of alkakios
alkakios

asked on

Delphi to C++, please help me..

I have this code in delphi, but i need it for my c++ project. I dont know what functions are equivelant to c++, so can someone help? The variable Area is a 'pointer' in delphi, the mapSize is 'integer', the AreaFile is 'file'. The problem is that I dont know what the GetMem, AssignFile, etc etc functions are in c++. Can someone help me translate this code?? Thanks a lot!

  GetMem(Area, (mapSize + 1) * (mapSize + 1));
  AssignFile(AreaFile, MAPFILENAME);
  Reset(AreaFile, 1);
  BlockRead(AreaFile, Area^, mapSize * mapSize);
  CloseFile(AreaFile);

Avatar of alkakios
alkakios

ASKER

Somebody help pls!
ASKER CERTIFIED SOLUTION
Avatar of robert_marquardt
robert_marquardt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello!

Exactly what language you need to convert to

Borland c++ Builder
Borland c++ 5
Microsoft visual c++.... ?

Im using VC++6
And robert, thank you very much, i will try it now! (ill give u the points soon)
Oh, one more thing about arrays! I have a variable declaration in delphi like this: (2DArray)

LandData   : array[0..nofQuads - 1, 0..nofQuads - 1] of TQuad;

I try to do a 2d array in C++ like this:

TQuad*  LData;

LData = new TQuad[nofQuads-1][nofQuads-1];

but it shows me this error: error C2440: '=' : cannot convert from 'struct _TQuad (*)[8]' to 'struct _TQuad *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Any ideas? the nofQuads is 8. i tried using 7 in the [][] but i still get the same error.
Oh, one more thing about arrays! I have a variable declaration in delphi like this: (2DArray)

LandData   : array[0..nofQuads - 1, 0..nofQuads - 1] of TQuad;

I try to do a 2d array in C++ like this:

TQuad*  LData;

LData = new TQuad[nofQuads-1][nofQuads-1];

but it shows me this error: error C2440: '=' : cannot convert from 'struct _TQuad (*)[8]' to 'struct _TQuad *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Any ideas? the nofQuads is 8. i tried using 7 in the [][] but i still get the same error.