[*]
While in pre-C++11 times implicit conversion from string literal (type const char[*]
) to char*
was only deprecated, since C++11 that’s an error (actually modifying it was UB earlier already).
Create a modifiable array and use that instead, like so:
static char argv_0[] = "pingpong";
static char *argv[] = {argv_0};
Be aware that the argument to main
also has a sentinel null-pointer though.
If you are really sure they just got their const
wrong, explicit casting may work too, though it’s a really dirty hack. Better refrain, and clean it up.
[*]
solved How do I prevent a compiler warning when I assign a string literal to static char *argv[]