Вам просто нужно использовать strings :: c_str ()
string final;
const char *pp = final.c_str();
Если вам нужно получить строковые данные в char*
, а не const char *
, тогда вам нужно copy
это так:
std::string final;
//Allocate pointer large enough to hold the string data + NULL
char *pp = new char[final.size() + 1];
//Use Standard lib algorithm to copy string data to allocated buffer
std::copy(final.begin(), final.end(), pp);
//Null terminate after copying it
pp[final.size()] = '\0';
//Make use of the char *
//delete the allocated memory after use, notice delete []
delete []pp;