Friday, August 15, 2008

c++ string to char*




How to convert a C++ string to a char* from a post at devx.


std::string s="hello";
const char *p = s.c_str(); // get const char * representation
int len = strlen(p);