Biggest problems w/ D - strings
BCS
ao at pathlink.com
Fri Aug 10 15:11:31 PDT 2007
Reply to Sean,
> 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
>
He might be using a D char[] as an oversized buffer for a c style string.
More information about the Digitalmars-d
mailing list