cstrings

Mafi mafi at example.org
Sun Jan 2 03:56:35 PST 2011


Am 02.01.2011 05:12, schrieb Ellery Newcomer:
> are there any other cstring -> dstring functions than to!string(char*) ?
>
> something like to!(char[])(char*)
>
> (the memory allocation bothers me)

You can simply make a slice. Indexing and sclicing works also with 
c-style pointers in D. Obviously $ is not allowed because bare pointers 
don't have a length.
poinetr[0 .. strlen(pointer)]
Be sure to not give this array to functions which relies on your char[] 
to be GC-allocated.


More information about the Digitalmars-d-learn mailing list