1.赋值方式

string str = "hello world";

 char *b="helllo2";

 

2.转化1

 char *b="helllo2";

string m=b;

3.转化2

string str = "hello world";

 const char* u;

 

  u= str.c_str()

  即str.c_str() = u;

4.CCString是Cocos2d-x自己封装的字符串类,只要是Cocos2d-x封装的类,都能自动管理内存,一般不需要我们关心。

CCString有个getCString函数,可以获取const char*对象。

相关文章: