I have the following code:
glShaderSource(shader, 1, (const char **)data.c_str(), NULL);
But it makes my program crash. How do I convert
I only want to point out that the pointer returned by c_str()
is only valid as long as you don't do anything that requires reallocation of the internal buffer of std::string. That invalidates the pointer you got.
But since you really require a **
i would do this:
const char* mychararr[1] = {data.c_str()};
glShaderSource(shader, 1, mychararr, NULL);
That should work nicely as long as you don't leave the scope of mychararr.