C++

From Omnia
(Redirected from Programming/c++)
Jump to navigation Jump to search

Convert String to Char

const char* string1 = str1.c_str();
std::string str;
const char * c = str.c_str();
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
// do stuff ...
// don't forget to free the string after finished using it
delete[] writable;

References:

keywords