string res; char* charRes = new char[res.length() + 1]; strcpy(charRes, res.c_str()); charRes[res.length()] = '\0';