I'm using a function from SDL, and one of the parameters is of type const GLchar* const*
, so in order to call it, I would need to pass in a reference of a C-string like this:
const char *str = "test";
glShaderSource(... , &str, ...);
However, I have an std::string
that I want to pass in, and doing something like this gives an error:
std::string str = "test";
glShaderSource(... , &str.c_str(), ...);
I know that I can simply make a new const char*
variable and save the std::string
to it like this:
const char *cstr = str.c_str();
But is there any way around this? I don't like having to make a new variable. I tried using a lambda but that didn't work.