假如是 字符串是 “hello” 后边要连接一个int类型
这个label setstring的时候。。这个字符串怎么拼啊??搜索了半天。。c++没有好的string连接的方法么??都好麻烦
谢谢 大神们!
假如是 字符串是 “hello” 后边要连接一个int类型
这个label setstring的时候。。这个字符串怎么拼啊??搜索了半天。。c++没有好的string连接的方法么??都好麻烦
谢谢 大神们!
没人帮忙吗
假设是现在这种情况:
std::string m_str = “hello”;
int num = 10;
char buf_str;
sprintf(buf_str,"%d",num);
m_str += buf_str;
label->setString(m_str);//OK
good sample to show lhhah
关注本帖(如果有新回复会站内信通知您
label->setString(CCString::createWithFormat(“hello%d”,number)->getstring());
谢谢各位帮助
3.0用__String::createWithFormat(),这个函数的用法就和c语言的pritef一样,你试试。
最后用以下做的。。
std::string num = StringUtils::toString(_destroyNum);
_label->setString(“击杀:” + num);
也就是这个 template
static std::string toString(T arg)
{
std::stringstream ss;
ss << arg;
return ss.str();
}
cocos给了个
CCString::createWithFormat(“hello%d”, num)->getCString()