zero-terminated strings, string literals, etc

David d at
Tue Oct 2 08:29:27 PDT 2012

Am 02.10.2012 16:55, schrieb Regan Heath:
> Recent discussions on the zero terminated string problems and
> inconsistency of string literals has me, again, wondering why D doesn't
> have a 'type' to represent C's zero terminated strings.  It seems to me
> that having a type, and typing C functions with it would solve a lot of
> problems.

You have basically a type only used for 0-terminated strings, char*, in 
D you use normally string, and if you wanna represent binary data you 
use ubyte[], I've never used char* except for interfacing with C. I 
would prefer a library soulution, some kind of Struct which is 
implicitly convertable to char* (0-terminates) and also to string (not 
0-terminated), not sure how to implement that though.

More information about the Digitalmars-d mailing list