Convert string[] to char**

bearophile bearophileHUGS at lycos.com
Tue Jun 4 03:41:28 PDT 2013


Jacob Carlborg:

> I think you need to do something like:
>
> import std.conv;
>
> string[] mykeys;
> char*[] ckeys;
> ckeys.reserve(mykeys.length);
>
> foreach (key ; mykeys)
>     ckeys ~= to!(char*)(key);
>
> foo(ckeys.ptr);

An alternative is something like (untested):

auto ckeys = mykeys.map!toStringz.array;

Bye,
bearophile


More information about the Digitalmars-d mailing list