is it possible to manually increment a pointer to get the next element in memory? if so, how much should it be incremented by to get the next integer in a series of integers in memory?
Assuming you mean a series of integers to be an array of integers then the following example code might be of help.
Code:
var
i: integer;
ints: array [ 0.. 15 ] of integer;
ip: ^integer; // Pointer to an integer
begin
// Fill array with predictable numbers
for i := Low(ints) to High(ints) do
ints[i] := i + 100;
ip := @ints; // Point to first array element
ShowMessage ( IntToStr ( ip^ ) );
inc ( ip, sizeof(integer) ); // Point to next element
ShowMessage ( IntToStr ( ip^ ) );
end;
Note that actual value to be incremented is best avoided by using the sizeof() function. This makes the code more robust (anticipating 64 bit integers?) and portable.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.