On 7/25/22 06:51, ryuukk_ wrote:
> On Monday, 25 July 2022 at 11:14:56 UTC, pascal111 wrote:
>> const(char)[] ch1 = "Hello World!";
>> char[] ch2="Hello World!".dup;
[...]
> `ch1`is a string literal, just like in C, it is null terminated
To be pedantic, ch1 is not the string literal but a slice of it. "Hello
world" is the string literal and does have a '\0' at the end.
> `ch2` is a GC allocated char array, it is NOT null terminated
Yes. The only difference between ch1 and ch2 is that ch1 does not incur
an allocation cost.
Ali