I have a method that is having the following signature:
size_t advanceToNextRuleEntryRelatedIndex( size_t index, size_t nStrings, char const *const *const strings)
How do I interpret this: char const *const *const strings
?.
Thanks, Pavan.
char const *const *const strings
^ v ^ v ^ v
| | | | | |
+----- +--+ +--+
so basically it means all pointers and the strings that the pointers point to are constant, meaning the function cannot modify the passed strings in any way (except if it gets casted).
e.g.
char* p[] = {"string1","string2"};
which will decay into char**
when passed to
int n = 0;
advanceToNextRuleEntryRelatedIndex( n, 2, p);
In char const *const *const strings
, strings
is a pointer to a char
pointer. Without the const
qualifiers it would look like this:
char **strings;
The const
qualifiers prohibit modifying the dereferenced value at the particular level of dereferencing:
**strings = (char) something1; // not allowed because of the first const
*strings = (char *) something2; // not allowed because of the second const
strings = (char **) something3; // not allowed because of the third const
In other words, the third const says that the pointer itself is immutable, the second const says that the pointed-to pointer is immutable and the first says that the pointed-to character is immutable.
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