I have the following code:
glShaderSource(shader, 1, (const char **)data.c_str(), NULL);
But it makes my program crash. How do I convert std::string
into const char **
?
I also tried (const char **)&
but it said "requires l-value" which I don't understand. It works fine when I use this code:
const char *data = "some code";
glShaderSource(shader, 1, &data, NULL);
But I can't make it work directly from a std::string
. I could allocate a new char
array for it but that is not nice code.
I also tried with const GLchar
but obviously it makes no difference.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…