On Saturday, 13 September 2014 at 17:31:18 UTC, ketmar via Digitalmars-d-learn wrote:
On Sat, 13 Sep 2014 17:09:56 +0000
WhatMeWorry via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com>
wrote:

I guess I was expecting them to be equivalent. I can understand why both lengths are zero. But what is emptyStr.ptr doing with the 42F080 value? I presume this is a address? If so, what does this address contain and what is it used for?
it's used to keep "empty string". ;-)

note that "null string" and "empty string" aren't same things. arrays are reference types and compiler magically knows that "null-arrays" are just empty arrays (and you can assign 'null' to array to clear it).

but strings are special in one funny way: when compiler sees string literal (i.e. quoted string) in source code, it actually generates C-like zero-terminated string. this is to ease C interop, so we can call C functions like this: `printf("my string!\n");` instead of this:
`printf("my string!\n".toStringz);`.


D string are actullay C-strings?

Reply via email to