1, char* turn string
char* cp = "char"; std::string SP = CP;
2. String Turn char*
1std::string str = "string"; const char* CP = Str.data ();//2std::string str = "string"; const char* CP = STR.C_STR ();//3st d::string str = "Hello"; char p[10];str.copy (P, 4, 1);//Here 4, which represents a copy of several characters, 1 represents the starting position of the copy index* (p + 4) = ' + '; To manually add a terminator
3, int turn string
int number = 32;char temp[10];sprintf (temp, "%d", number, ten); std::string s = temp;
4. Cocos2d proprietary Conversion method
int index = 100;std::string str = value (index). asstring (); int index2 = value (str). Asint ();
This article is from the "Grape Sweet vinegar" blog, please be sure to keep this source http://putaotiancu.blog.51cto.com/8627957/1599390
COCOS2DX Study Notes (2) string char* int type data conversion