[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Delphi to C++, please help me..

Posted on 2002-06-24
6
Medium Priority
?
225 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 240 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

650 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