How to prove const char *p is same as char const *p through code or memory space model or any other things.
For example, I defined:
const char *p;
char const *p;
Now from where I can know they take same effect?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is a matter of style more than anything else.
As for the proof part: They are equivalent because the language rules ensure that both syntax have the same semantics. As such, implementations are required to make sure that they have the same effect. You may want to read Stroustrup’s FAQ item: Should I put “const” before or after the type? (though note that C and C++ are different languages, the latter borrowing heavily from the former and to this day does try to maintain compatibility.)
The
constkeyword is an exception in the sense that in this case the C standards committee borrowed something from C++ and retrofitted it to C.