Кроме того, вы можете использовать векторы, чтобы получить записываемый символ *, как показано ниже;
//this handles memory manipulations and is more convenient
string str;
vector <char> writable (str.begin (), str.end) ;
writable .push_back ('\0');
char* cstring = &writable[0] //or &*writable.begin ()
//Goodluck