On Saturday, 13 September 2014 at 23:22:40 UTC, ketmar via Digitalmars-d-learn wrote:
On Sat, 13 Sep 2014 22:41:38 +0000
AsmMan via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com>
wrote:

D string are actullay C-strings?
in no way. only string *LITERALS* are zero-terminated.

Ok. So I wrote the following:

char c = *(emptyStr.ptr);
if (c == '\0')
   writeln("emptyStr only consists of an end of line character");

and sure enough, the writeln() was executed.

Ok, So an empty string has a pointer which just points to C's end of line character.


So is one form (Empty strings versus null strings) considered better than the other? Or does it depend on the context?

Also as an aside (and I'm not trying to be flippant here), aren't all strings literals? I mean, can someone give me an example of a string non-literal?

Reply via email to