Possible Duplicate:
about “int const *p” and “const int *p ”
Difference between
const char *p
and
char * const p?
is that fist one means cannot change char. Later one means cannot change the pointer. Am I right? Thank you!
Possible Duplicate:
about “int const *p” and “const int *p ”
Difference between
const char *p
and
char * const p?
is that fist one means cannot change char. Later one means cannot change the pointer. Am I right? Thank you!
const char *p
means the characters cannot be changed. *p = '\0'
is illegal. Var p
is a pointer to a const char
.
char * const p
means the pointer cannot be changed. p = 0
is illegal. Constant p
is a pointer to a char
.
const char * const p
means neither can be changed. Constant p
is a pointer to a const char
.
Update: Added third declaration.
In the first you can't edit the pointee and in the second you can't edit the pointer. Have a look at this perhaps.