converting a char[][] to a char**
BCS
BCS_member at pathlink.com
Fri Apr 21 09:18:55 PDT 2006
In article <e29eol$5sa$1 at digitaldaemon.com>, glen says...
>
>Hi All,
>This seemingly simple thing is causing me alot of trouble. Can someone show me
>how I can convert an array of char[][] to a char**.
>
>Here is the pseudo code...
>
>void runWithArgs( char[][] args ) {
>char** execArgs;
>
>// convert args to execArgs
>
>execv( toStringz( "myprog" ), execArgs );
>
>}
>
>
>thanks,
>Glen
>
>
this is quick and dirty but should work
char[][] src; // what to convert
alias char* cahr_p;
// alias b/c I can't remember the syntax for a array of ptrs
char_p[] res = new char_p[src.length+1];
foreach(int i, char[] st, src)
res[i] = st.ptr;
res[$-1] = null;
// now use
res.ptr
More information about the Digitalmars-d
mailing list