F
Frederick Gotham
benben posted:
Incorrect. The type of "Hello" is: char[sizeof"Hello"]
It is an array, not a pointer.
I would advocate defining "p" as const, because we don't want its value to
change until we call "delete".
char *const p = new char[6];
Try not to do that. A string literal is of type const char*.
Incorrect. The type of "Hello" is: char[sizeof"Hello"]
It is an array, not a pointer.
If you want to modify, why put up with const in the first place?
Either do
char p[] = {'h', 'e', 'l', 'l', 'o', 0};
p[0] = 'K'; // OK
or
char* p = new char[6];
I would advocate defining "p" as const, because we don't want its value to
change until we call "delete".
char *const p = new char[6];