Hi friends!
What is the difference between these two definitions of variables?
const char *msg;
char* const msg;
thanks in advance)
Hi friends!
What is the difference between these two definitions of variables?
const char *msg;
char* const msg;
thanks in advance)
const char *msg
is a pointer to const char. char* const msg
is a constant pointer to char. In the former case the object being pointed to is const and cannot be modified, but the pointer can be changed to point to another object. In the latter case the pointer is const and cannot be pointed to another object, but the object being pointed to may be modified.
A third case could be where both are const:
const char* const msg;
Narue,many thanks for detailed answer and the third variant!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.