I have an opengl function that requires a const char**. So essentially a vector of strings. I was wond开发者_Go百科ering if this could be done using the C++ Standard Library without making a vector of const char* which would demand heap allocation.
If you're wanting to avoid heap allocation:
const char* arrayOfStrings[] = {
"first string",
"second string",
"third string"
};
And you can use arrayOfStrings as a const char**.
If you have a vector of const char*s you can just get the address of the first element to obtain a const char**:
&vec[0];
However, what do you mean when you say "using [c++ standard library]"? You say you want to "use the [C++ standard libary] without making a vector of const char*". That doesn't make much sense.
You don't need the standard library for this, please clarify your question if my answer isn't sufficient.
加载中,请稍侯......
精彩评论