Is it possible for different <const char*> variables to overlap?

  arrays, c++, c++11, compiler-construction

If I initialize several const char* variables in the following ways:

const char* myString1 = "string content 1";
const char* myString2 = "string content 2";
...

Since const char* is simply a pointer a specific char object, it does not contain any size or range information of the character array it is pointing to.

So, is it possible for two string literals to overlap each other? (The newly allocated overlap the old one)

How does C++/compiler avoid such problem?

If I change const char* to const char[], is it still the same?

Source: Windows Questions C++

LEAVE A COMMENT