char * const a;
const char * a;
One is a constant pointer to a char. The other is a pointer to a char const.
I think there is a specific way. Something like order of execution. I think there should be brackets around or something.
Can anyone explain to me why the pointer is const on one and not the other?
char * const a, for example.
Does that become (char *) const a
Or
const char * a
Is it (const (char *)) a
In What is the difference between const int*, const int * const, and int const *? I got a bunch of explanations that do not seem to make sense.
One explanation is to read it backward.
Another explanation is to split the * and see if the const is on the right or left.
Then there is another bizare theory of doing it clockwise
http://c-faq.com/decl/spiral.anderson.html
The rules do not seem like the real actual formal rule. I am not even sure if the rule holds for even more complex types. Not to mention the rules only work in english.
Okay, what's the actual formal rule here and what's the reference?
I think there has to be a simpler rule on why this is so.
For example, does the word const apply to the left or right? Can we put brackets like I suggest?