3/06/2014

(c, c++) 'char * to string' and 'string to char *'

//string to char*

string str = "hello";
char cstr[10];
strcpy(cstr,str.c_str());
 
// char * to string

char cstr[] = "hello";
string str = cstr; //string(cstr)

No comments:

Post a Comment