On Sunday, 22 January 2017 at 15:59:47 UTC, Suliman wrote:
On Sunday, 22 January 2017 at 15:51:01 UTC, Suliman wrote:string str = "abc"; writeln(str.ptr); str = "def"; writeln("last data: ", *(str.ptr)); writeln("old data: ", *(str.ptr-1)); // print nothing writeln("old data: ", *(str.ptr-2)); // print cIt's look like that there is some gap between data, because `d` minus 1 should be `c`, but `c` I am getting only if I am doing `-2`. Why?writeln("old data: ", cast(int)*(str.ptr-1)); #old data: 0 String is gaping by zero?? I thought they are continuously like abcdef ---↑ Where `↑` is equal to `ptr`.
You have *two* distinct strings here. Why do you expect them to be sequential in memory? If you want them to be treated as one string, concatenate them.
auto s1 = "abc"; auto s2 = "def"; auto s3 = s1 ~ s2;
