I want to send the values manually here
void processArgs(int argc, char** argv);
if I sending like this
char* cwd[] = {"./comDaemon", "--loggg=pluginFramework:debug"};
parser->processArgs(2, cwd);
compiler showing warning as
warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
char* cwd[] = {"./comDaemon", "--loggg=pluginFramework:debug"};
Others have noted that the problem is you're trying to pass string literals (which are const) to a function that takes a non-const char **
argument. If what you want is to create non-const strings that you can pass to your non-const arg function, you need explicit char arrays (which you can initialize with string literals):
char arg0[] = "./comDaemon";
char arg1[] = "--loggg=pluginFramework:debug";
char *cwd[] = { arg0, arg1 };
you could even do this all on one line:
char arg0[] = "./comDaemon", arg1[] = "--loggg=pluginFramework:debug", *cwd[] = { arg0, arg1 };
If the function you're passing cwd
to expects char **
argument, instead of const char **
, here is one way:
char *cwd[] = { const_cast<char *>("value1"), const_cast<char *>("value2") };
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