Generate an array of char* pointers from a function
<p>I have a C++ function to which I have to pass <code>char* arguments[]</code>. The prototype of this function is as follows:
<code>void somefunc(char* arguments[])</code></p>

<p>To pass the above array to this function, I am generating this array from another function which can return me this <code>char* array</code> output, and this looks somehwhat like this.</p>

<pre><code>char** genArgs(int numOfArgs,...)
{
    va_list argList;    
    char** toRet = new char*[numOfArgs];
    va_start (arguments, numOfArgs);
    for(int cnt = 0; cnt &lt; numOfArgs ; ++cnt)
        toRet[cnt] = va_arg(argList, char*);

    va_end(arguments);
}
</code></pre>

<p>I am confused how to actually write the above function correctly, given that I will be passing the inputs to function something like : <code>genArgs(3, a.c_str(), b.c_str(), c.c_str())</code> or <code>genArgs(2, a.c_str(), b.c_str())</code> <br/>
How can I generate the above char* array without using char** (since this would have to be deleted before returning from the function to avoid memory leak).</p>
