converting c's c* to d strings

Jarrett Billingsley kb3ctd2 at yahoo.com
Sat Jun 28 18:55:39 PDT 2008


"torhu" <no at spam.invalid> wrote in message 
news:g46fa8$1hli$1 at digitalmars.com...
> Xinok wrote:
>> llee wrote:
>>> Does anyone know how to convert from character array pointers in c to d 
>>> strings using Phobos?
>>
>> You can convert any pointer type to an array type using slicing.
>>
>> import std.c.string;
>> char* cstr;
>> string dstr = cstr[0..strlen(cstr)];
>
> Or you can use std.string.toString().  It's cleaner, but slower because it 
> copies the string.

No is isn't, it does the exact same thing as what was posted above (cstr[0 
.. strlen(cstr)]). 





More information about the Digitalmars-d mailing list