cocos2dx and c++ 的小坑
发布时间:2020-12-14 16:35:10 所属栏目:百科 来源:网络整理
导读:char[] 大小 char[x] 当时没注意这个 因为需求中 这里需要格式化的只有1、2、3、4这几种情况都是大小为1的 结果出现如下错误 原因应该是 只能容下 x-1 个字符 必须保留最后一个字符作为结尾判断 否则不知道如何释放 Run-Time Check Failure #2 - Stack aroun
Value(int).asString();// 函数里面调用的是 std::stringstream ret;
char str[255];
sprintf(str,"***%d**",index); 这种 太麻烦了 好累
std::function<void(void)> //赋值空 应该用 nullptr
//action->setCurrentFrame(10 * n);//这个看起来很像但是不行
action->gotoFrameAndPause(10 * n);
#include <string> //#include <string.h> 不要使用后者 (我当时的情况就不能用后者 android编译出错)
来源于互联网
bool AppDelegate::isFileExist(const char* pFileName)
{
if (!pFileName) return false;
std::string filePath = FileUtils::getInstance()->getWritablePath();
filePath += pFileName;
FILE *fp = fopen(filePath.c_str(),"r");
if (fp) {
fclose(fp);
return true;
}
return false;
}
void AppDelegate::copyData(const char* pFileName)
{
if (isFileExist(pFileName)) {
return;
}
std::string strPath = FileUtils::getInstance()->fullPathForFilename(pFileName);
ssize_t len = 0;
unsigned char *data = NULL;
data = FileUtils::getInstance()->getFileData(strPath.c_str(),"r",&len);
std::string destPath = FileUtils::getInstance()->getWritablePath();
destPath += pFileName;
FILE *fp = fopen(destPath.c_str(),"w+");
fwrite(data,sizeof(char),len,fp);
fclose(fp);
delete[]data; data = NULL; }
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |