tmf wrote: This is how you define a pointer to a string literal, which in C has type char[]. Modifying a literal, via such a pointer, is an undefined operation in C and is wrong.
.
Where did I write that such a modification of a literal is correct? A text string (a string of characters) is not necessarily the same as a literal (an unmodifiable string - a string constant).
tmf wrote: the compiler has every right to concatenate (albeit not necessarily) the same literals.
.
Exactly what I wrote about in post #39.
tmf wrote: Interestingly, an operation of this type without explicit casting in C++11 is already an error.
.
With explicit casting it is also a bug i.e. const char* should not be cast to char* - this is dangerous and can end up with a program crash. It is also worth reading what the difference between const in C and C++ is.
tmf wrote: The operation char change[] = "literal" copies a literal into an array, each time generating a new copy of the text literal. In this case, such an operation should be used.
.
There is no need to do this, just reserve an array of the appropriate size - I wrote about this in also post #39. In the rest of the Author's program, it is sprintf() that takes care of constructing the text string using this array.
I was hoping that colleague
@tmf would respond to the following bit of code from colleague
@LED5W , which is complete nonsense, instead of assuming in advance that "I am wrong":
LED5W wrote: This is basically the same as
.
.