In the event that you simply need to pass a
std::string
to a capacity that needs
const char
you can utilize
std::string str;
const char c = str.c_str();
In the event that you need to get a writable copyy, similar to
char
, you can do that with this:
std::string str;
char writable = new char[str.size() + 1];
std::copy(str.begin(), str.end(), writable);
writable[str.size()] = '\0'; // don't forget the terminating 0
// don't forget to free the string after finished using it
delete[] writable;