0

I don't know how to access the content of an array of pointers by a pointer. Here's an example:

Type
    PInteger = ^Integer;
    IntegerArrayP = array of PInteger;
    PIntegerArrayP = ^IntegerArray;

var
    variable: Integer;
    parrp: PIntegerArrayP;
    arrp: IntegerArrayP;
begin
    SetLength(arrp, 5);
    parrp := @arrp;
    For variable := Low(arrp) to High(arrp) do
    begin
        arrp[variable] := New(PInteger);
        (parrp^)[variable]^ := variable;
        WriteLn('parrp: ', arrp[variable]^);
    end;
end.

In my opinion it should be done like this (ptabp^)[variable]^ := variable; But I guess I'm wrong.

1 Answer 1

1

You are right. Parens might be omitted.
What pascal compiler do you use? Proper usage of New routine:

 New(arrp[variable]) ;
 parrp^[variable]^ := variable;

P.S. Do you really need these pointer types here?

P.P.S. Now I see an error: PIntegerArrayP = ^IntegerArrayP;

Sign up to request clarification or add additional context in comments.

3 Comments

I'm using free pascal. I've also tried to compile it on an online compiler. Check it out here: ideone.com/rSkhTQ
Well I don't need all of these pointer types. I'm just practising.
You mixed common type and your own type by accident. See addition

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.