argv is an array of constant pointers to characters
char * const argv[] // 1
argv is an array of pointers to characters, which are constant
const char * argv[] // 2
Is there a tip to remember number 1?
const char * argv[] // 2
can also be written:
char const * argv[] // 3
because C doesn't care about the order of const in the type. If you write it this way, then the thing actually const
is the thing to the left of the keyword const
. The form where const
is first is the one exception to that rule; but in that case there's nothing to the left of const
so it is easy to avoid that case with this rule of thumb.
char* // mutable pointer to mutable char
char const* // mutable pointer to constant char
char * const // constant pointer to mutable char
char const* const // constant pointer to constant char
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With