您的位置:首页 > 移动开发 > Cocos引擎

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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: