char* – pointer to a variable of type char.
char* const – a constant pointer.
const char* – pointer to a constant variable.
const char* const – a constant pointer to a constant.
char const* is the same as
const char* . It is automatically converted to it.
But the gcc(c99) compiler talks about
char* const* as a separate type. Same with
const char* const* . What is the meaning of
const together with
char* ? How to describe this type?
This is the same pointer to pointer as
char** , but you cannot change its address (of the pointer to which the variable points).
char* pc1 = (char*)malloc(LENGTH); strcpy(pc1, "Hello"); char* pc2 = (char*)malloc(LENGTH); strcpy(pc2, "World"); char* const* ppc1 = &pc1; // OK *ppc1 = pc2; // compile-time error char** ppc2 = &pc1; // OK *ppc2 = pc2; // OK