Solved

Delphi to C++, please help me..

Posted on 2002-06-24
6
200 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
  • 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now