what's the right way to get char* from string?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 5 08:34:53 PDT 2016


On 5/5/16 3:36 PM, Steven Schveighoffer wrote:
> Only thing I can think of is.. um... horrible:
>
> char *toCharz(string s)
> {
>     auto cstr = s.toStringz;
>     return cstr[0 .. s.length + 1].dup.ptr;
> }

Ignore this. What Jonathan said :)

-Steve



More information about the Digitalmars-d-learn mailing list