Can't understand if deallocation happens?

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 22 23:52:16 PST 2017


On Monday, 23 January 2017 at 06:42:00 UTC, Suliman wrote:
>> You have *two* distinct strings here.
>
> Yes, I understand, I am trying to find out how it's work on low 
> level. Any ideas why zero is used?

string *literals* in d are nul terminated to ease interoperation 
with C

so
string s = "foo";
writefln("%d",cast(ubyte)s.ptr[3]); // use '.ptr' to skip bounds 
check

prints 0u


More information about the Digitalmars-d-learn mailing list