Solved

Delphi to C++, please help me..

Posted on 2002-06-24
6
214 Views
Last Modified: 2010-08-05
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);

0
Comment
Question by:alkakios
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 

Author Comment

by:alkakios
ID: 7104261
Somebody help pls!
0
 
LVL 11

Accepted Solution

by:
robert_marquardt earned 80 total points
ID: 7104417
This is plain C.

{
FILE *AreaFile;
char *Area;

Area = malloc((mapSize + 1) * (mapSize + 1));
AreaFile = fopen(MAPFILENAME, "rb");
fread(AreaFile, Area, mapSize, mapSize);
fclose(AreaFile);
}

Please have a look at the fread parameters. I may have mixed them up.
0
 
LVL 2

Expert Comment

by:freshman3k
ID: 7104436
Hello!

Exactly what language you need to convert to

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

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:alkakios
ID: 7105592
Im using VC++6
And robert, thank you very much, i will try it now! (ill give u the points soon)
0
 

Author Comment

by:alkakios
ID: 7105649
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.
0
 

Author Comment

by:alkakios
ID: 7105749
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question