Link to home
Start Free TrialLog in
Avatar of calvinrsmith
calvinrsmith

asked on

Pascal and pointers

I'm new to the way delphi / pascal handles pointers.
How does this C / C++ code map to delphi?

the idea here is to create a buffer of two integers

void pointertest(void)
{
   void *p;
   char TheData[8];
   
   p = TheData;
   *p = 9;
   *(p + 4) = 100;
   
   return;
}

and also this one where p is two integers followed by a string
void pointertest(void *p)
{
   int int1;
   int int2;
   char *thestring;

   int1 = *p;
   int2 = *(p+4);
   thestring = *(p+8);

   return;
}
ASKER CERTIFIED SOLUTION
Avatar of rwilson032697
rwilson032697

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
Avatar of rwilson032697
rwilson032697

Oops, the first one shoudl look like this:

Procedure PointerTest;
var
 p : ^Integer;
 thedata : array[1..8] of char;
begin
  p := @TheData;
  p^ := 9;
  inc(p);
  p^ := 100;
end;

Cheers,

Raymond.