I am trying to call function void func(char** argv)
with a string literal "test.exe" in C++.
My current solution is
char* name = "test.exe";
func(&name);
However, the compiler complains since string literals are of type const char*
. What is the current recommended way to resolve this?
I've read several answers, here, here, here, etc, but all the answers I've found are either:
Use std::string::c_str() which I don't want to do since I don't want to allocate the memory for a new std::string, or
Change func to take a
const char *
, which I cannot do as it is contained in an external library.