On Tuesday, 5 November 2019 at 08:47:05 UTC, Ferhat Kurtulmuş wrote:

value of int which is 0. I wonder how new memory is allocated without an explicit malloc here. Sorry for this noob question in advance, I could not find any doc mentioning a similar case.


    int* vals = cast(int*)malloc(len * S.sizeof);
    vals[0] = 4;
    vals[1] = 5;

    S s1 = S(vals, len);

    S s2 = s1;

    writeln(s2.vals[0]);

      writeln(s2.vals);
      writeln(s1.vals);

}

https://run.dlang.io/is/D0nfeT

Reply via email to