cocos2d int, float, double, const char* 转string
2015-07-20 16:22
169 查看
(1)int, float, double 转 string
int i = 100;
std::string str = StringUtils::format("%d", i);
float f = 100.1f;
std::string str2 = StringUtils::format("%f", f);
double d = 100.2;
std::string str2 = StringUtils::format("%d", d);
(2)const char* 转 string
const char* 可以直接复制给string
(3)组合拼接
int i = 1;
std::string str = StringUtils::format("people%d.png", i);
std::string str2 = StringUtils::format(%s%d.png", "people", i);
int i = 100;
std::string str = StringUtils::format("%d", i);
float f = 100.1f;
std::string str2 = StringUtils::format("%f", f);
double d = 100.2;
std::string str2 = StringUtils::format("%d", d);
(2)const char* 转 string
const char* 可以直接复制给string
(3)组合拼接
int i = 1;
std::string str = StringUtils::format("people%d.png", i);
std::string str2 = StringUtils::format(%s%d.png", "people", i);
相关文章推荐
- (跨平台)cocos2d-x C++ or Object-C(前端)调用C# webservices(后台),实现交叉编译到Android/IOS/WinPhone等移动终端设备
- cocos2d-x 3.2 它 三消游戏——万圣节大作战
- cocos studio 把excel导成json
- Cocos Studio 查看plist文件
- 我的COCOS2D-X 3.0适配方案
- cocos2d 物理引擎锚点
- Cocos2d-x Vector——vector iterators incompatible
- cocos2d-x 新手引导(矩形,圆形的强制引导)
- cocos2d 3.X Shader 变暗和变灰
- cocos2dx APP图标文件更改(xcoder上传Archive ITMS-90032错误)
- cocos2d-x百分比读取进度及资源加载
- CREATE_FUNC
- cocos2d-x 3.2 它 2048 —— 第三
- 基于cocos2dx-js开发的仿《英雄难过棍子关》
- 【cocos2d-js公文】十八、Cocos2d-JS v3.0物业风格API
- 记录一下cocos2d-x——开发环境安装
- 我对自己提的几个关于cocos2dx的几个问题
- 3.cocos2dx它Menu,由menu为了实现场景切换
- Cocos2d-x使用UserDefault数据持久化实例
- quick cocos工程编译到手机上