The weather will be fine on Monday, February 1, 2021 [Do not lament the past, do not waste the present, do not fear the future]
Contents of this article
1. const char* and char const* are equivalent
The C++ standard stipulates that const
keywords placed before the type or variable name are equivalent, so const char*
and char const*
are equivalent.
const char *p; //same as below
char const *q;
2. The difference between const char* and char* const
As for const char *p
sum char* const q
, according to the principle of proximity: the former const
modification *p
means that the content pointed to by the pointer cannot be changed, and the latter const
modification q
means that the value of the pointer itself cannot be changed.