C++
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:
- c++ - How to convert a std::string to const char* or char*? - Stack Overflow - http://stackoverflow.com/questions/347949/how-to-convert-a-stdstring-to-const-char-or-char
- c++ - std::string to char* - Stack Overflow - http://stackoverflow.com/questions/7352099/stdstring-to-char