Q:

Initialising char** in c++

I looked at most of related posts but unfortunately I couldn't get a satisfactory answer for my concrete case.
I am using a 3rd party library which has a structure with an attribute of char**, which I need to populate. I tried almost everything imaginable that I thought would be valid c++ syntax and would work, however I always get a run-time error trying to assign it.
To clarify I should say that the array of strings should take (i assume) names of files.
Consider this as our code:

    char** listOfNames; // belongs to the 3rd party lib - cannot change it
    listOfNames =       // ???

So my question is how to initialize this variable with one or more string file names, eg: "myfile.txt" ?
Should also be c++11 compatible.

A:

I think you should initialize the listOfNames as a dynamic string array and then initialize each element of the array as the following codes:
char** listOfNames; // belongs to the 3rd party lib - cannot change it

int iNames = 2; // Number of names you need

try
{
    // Create listOfNames as dynamic string array
    listOfNames = new char*[iNames];

    // Then initialize each element of the array
    // Element index must be less than iNames
    listOfNames[0] = "Hello";
    listOfNames[1] = "World";
}
catch (std::exception const& e)
{
    std::cout << e.what();
}

