String Theory Questions
    WhatMeWorry via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sat Sep 13 17:34:54 PDT 2014
    
    
  
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 at 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?
    
    
More information about the Digitalmars-d-learn
mailing list