On 08/27/2013 03:35 AM, (e-mail address removed) wrote:
....
char const * const *a_NextPtr;
would read as: a_NextPtr is a pointer constant pointer to a constant char?
if that's the case what does that mean? a pointer to an array of char(s) that can't
be changed?
C declarations are based upon the principle that the declaration of an
identifier reflects the way that it is used. There are additional
principles, and exceptions to that principle, but it is the most
fundamental principle that's relevant.
In this case, what that means is the for any given '*', the '*' and
everything following (after dropping qualifiers) is a model of a C
expression involving the identifier being declared. Everything to the
left of the '*' is the type of that expression. This rule requires
modification in some circumstances, and doesn't apply in a few others,
but it applies here.
The first '*' means is that the expression **a_NextPtr has the type
"char const" - so it is NOT a modifiable lvalue.
The second '*' means that the expression *a_NextPtr has the type "char
const* const" - the rightmost "const" indicates that this expression is
also not a modifiable lvalue.
a_NextPtr itself has the type "char const*const*"; the fact that there
is no 'const' after the second '*' indicates that a_NextPtr itself can
be modified.
So a_NextPtr is pointer to a const pointer to const char.