How do I assign a sequence of character strings to a char ** argv variable in a program? Its a command line argument. I'm currently trying to convert an .exe app to a dll.
For example:
{ "string1", "string2", "string3" } --- > char ** argv variable
My problem is somehow realted to this: How does an array of pointers to pointers work? but I can't get it to work using the snippet shown there. Help!
const char* argv[] = {"string1", "string2", "string3", 0};
If the arguments aren't compile time constants I would do something like:
std::vector<const char*> arguments;
arguments.push_back(somePointer);
arguments.push_back(someOtherPointer);
arguments.push_back(0);
const char** argv = &arguments[0];
EDIT: Using PaxDiablos information that an argv-array should be null terminated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With