For test purposes I have factored out my main code into do_something()
and am now calling it from main. However this doesn't work as my char[][] args array is too stubborn to be converted to char**. This is what I'm trying:
char args[1][15] = { { "www.google.com" } };
char** argv = args;
int argc = 2;
do_something(argc, argv);
Yields:
char [1][15]" cannot be converted to "char **"
I don't know why it can't figure out how to decay the pointers? Should be obvious? Do I really need to reinterpret_cast
this?
I've also tried this:
char* args[] = { "www.google.com" };
But now the meaning is different: Here I don't initialize the subarrays with google, but I create an array of pointers to static string literals. Which makes my compiler complain:
const char [15]" cannot be converted to "char *"
How would any of you solve this problem?
EDIT: What I really want to achieve is to pass the char array to a main-like function. I can only do that if it satisfies char* argv[]
. The question then is how do I get exactly this type from a non-const char[][]?