vendredi 23 janvier 2015

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.


Aucun commentaire:

Enregistrer un commentaire