2

I have struct A and following code: A *const *ppA What does this code mean? It is a pointer to a constant array? I'm not sure so I asked this question here

3
  • This is a pointer to a const pointer to a struct A stackoverflow.com/questions/1143262/… Commented Mar 3, 2014 at 12:47
  • 1
    Where do you get the array from? There's no array in the declaration. (Of course, any pointer might point to the first element of an array. Or not.) Commented Mar 3, 2014 at 13:16
  • 1
    @JamesKanze I'm using it as a pointer that point to the first element of an array so that's why :) Commented Mar 3, 2014 at 13:45

1 Answer 1

7

const and volatile qualify the type immediately before them (unless they appear at the beginning, in which case they qualify the type immediately after them); so you can read this from right to left:

ppA is a (non-constant) pointer to a constant pointer to a (non-constant) A.

There's no way to tell from the declaration whether it might be used to point to a single object, the first of an array, or no object at all.

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

Comments

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.