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*对象。

相关文章:

  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
  • 2021-06-16
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2021-06-26
猜你喜欢
  • 2021-11-22
  • 2022-01-16
  • 2021-06-30
  • 2022-12-23
  • 2022-03-07
  • 2021-09-03
相关资源
相似解决方案