12
std::string x="hello world"; char* y=x;
std::string x = "hello world"; char *y = x.c_str();
1234567891011
#include <cstring> #include <string> // ... std::string x = "hello world"; char *y = new char[x.length() + 1]; // or // char y[100]; std::strcpy(y, x.c_str()); delete[] y;
123
const char* foo = "Whatever"; string bar = foo;