Biggest problems w/ D - strings
Sean Kelly
sean at f4.ca
Fri Aug 10 14:58:12 PDT 2007
C. Dunn wrote:
> Kirk McDonald Wrote:
>
>> C. Dunn wrote:
>>> 4) Not enough help for converting between D strings and C char*.
>>> There must be conversion functions which work regardless of whether
>>> the D string is dynamic or not, and regardless of whether the C char*
>>> is null terminated. I'm not sure what the answer is, but this has
>>> lead to a large number of runtime bugs for me as a novice.
>>>
>> The std.string module has the toStringz and toString functions.
>
> I have a field of n chars stored on disk. It holds a null-terminated string, padded with zeroes. It is amazingly difficult to compare such a char[n] with some other char[] (which, by the dictates of D, may or may not be null-terminated).
I'm not sure I understand. Why bother computing string length in the C
fashion when D provides a .length property which holds this information?
Sean
More information about the Digitalmars-d
mailing list