D-DLLs & Python

John Colvin john.loughran.colvin at gmail.com
Tue Feb 19 14:26:20 PST 2013


On Tuesday, 19 February 2013 at 19:06:47 UTC, jerro wrote:
>> D doesn't use null termination for it's strings, strings are 
>> immutable(char)[]. You can form a D slice from a pointer by 
>> going
>> slice = ptr[0..length]
>> where length is the length of the array the pointer represents.
>> You can't just take a c style string and expect writeln to 
>> work with it.
>
> You can use std.conv.to to convert a C string to a D string.

Good to know.

If you do know the length beforehand though, slicing will O(1) as 
opposed to O(n)


More information about the Digitalmars-d-learn mailing list