Converting a C++ string to a char array is pretty straightorward using the c_str function of string and then doing strcpy. However, ho
#include
#include
#include
#include
using namespace std;
int main ()
{
char *tmp = (char *)malloc(128);
int n=sprintf(tmp, "Hello from Chile.");
string tmp_str = tmp;
cout << *tmp << " : is a char array beginning with " <
OUT:
H : is a char array beginning with 17 chars long
Hello from Chile. :is a string with 17 chars long