分享一下cocos2dx 返回字符串中字符串拼接的源代码,大家如果在写这方面的代码的时候可以参考一下,代码如下:
- for(int i=1;i<5;i++){
- char str[3];
- sprintf(str,"%d",i);
-
- char totalFilename[30];
- strcpy(totalFilename, "game_loading") ;
- const char* suffix = ".png";
- strcat(totalFilename, str);
- strcat(totalFilename, suffix);
- log(totalFilename);
- animation->setDelayPerUnit(0.2f);
- log("%d",sizeof(str[0]));
-
- char t = 'q';
- log("char %d",sizeof(t));
-
- float a = 10.30;
-
- log("t %d",sizeof(&a));
- animation->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(totalFilename));
- }