char* conf[1] = { "Seven" };
The
"Seven" is a
constant string literal. Those six bytes are in special part of the executable.
It is a huge error to attempt to modify that memory.
What the compiler actually gives us is the address of the first character in that block. The address of 'S'.
In other words, your code does:
1 2
|
const char* literal = "Seven";
char* conf[1] = { literal };
|
The
conf is an array of pointers. Array that has only one element. One pointer.
If you did not have an array, then your code would be:
1 2
|
const char* literal = "Seven";
char* one = literal;
|
The
literal has a memory address. You want to store the address in
one.
The both
literal and
one point to same constant string literal.
However,
one is not
const. It would be syntactically legal to modify via
one:
one[2] = 'X'; // would change "Seven" to "SeXen".
However, it is not legal to modify constant string literal.
The standard "C++ advice" is to use
std::string and not C-strings.