On Mon, Jul 25, 2022 at 05:30:14PM +0000, pascal111 via Digitalmars-d-learn wrote: [...] > int main(string[] args) > { > > > const(char)[] ch1 = "Hello World!"; > char[] ch2="Hello World!".dup; > > const(char) *p1; > char *p2; > > ch2~="\0"; > > p1=ch1.ptr; > p2=ch2.ptr; > > writeln(p1[0..strlen(p1)]); > writeln(p2[0..strlen(p2)]);
Unless you are passing the string back to C code as char*, there is no need to use strlen here. You can just use `writeln(p1);` to output the entire string, or slice it with `p1[0 .. $]` to get the entire string. T -- Being able to learn is a great learning; being able to unlearn is a greater learning.