- char[] 大小
char[x]
当时没注意这个 因为需求中 这里需要格式化的只有1、2、3、4这几种情况都是大小为1的 结果出现如下错误
原因应该是 只能容下 x-1 个字符 必须保留最后一个字符作为结尾判断 否则不知道如何释放
Run-Time Check Failure #2 - Stack around the variable ‘str’ was corrupted. int[] 赋值
最容易想到的赋值方式却出问题了要用以下的赋值方式
memcpy(mMapView,b.barriers,sizeof(b.barriers));cocos2d-x调用scheduleUpdate()不执行update()方法的解决办法
网上搜出来的
但是去掉方法这样肯定就不好了 如果你舍不得去掉onEnter方法 我们可以在子类中调用父类的对应方法 比如我的情况在自己实现的onEnter里面调用下Layer::onEnter();
这个其实很容易想到的 至少ios开发中太多这种了- int string 转换 cocos2dx适用
- 函数赋值空
- std::function<void(void)> //赋值空 应该用 nullptr
- 动画暂停到某一帧
- //action->setCurrentFrame(10 * n);//这个看起来很像但是不行
- action->gotoFrameAndPause(10 * n);
- boolean bool
不要使用boolean在编译android的时候报错 - string
- #include <string> //#include <string.h> 不要使用后者 (我当时的情况就不能用后者 android编译出错)
- 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; }