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;
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Procedure PointerTest;
var
p : ^Integer;
thedata : array[1..8] of char;
begin
p := @TheData;
p^ := 9;
inc(p);
p^ := 100;
end;
Cheers,
Raymond.