'new'无法创建阵列?

0 c++ memory

我正在精神上,将某些东西简化为简单,无论我怎样或者我尝试什么,阵列都无法工作?这是怎么回事?

代码只是来自cocos2dx的单个cpp helloworld.而已,

    double *Array = new double[333];
if (Array == nullptr)
    CCLOG("Error: memory could not be allocated");

//initialize it
for( int i = 0; i != 333; ++i){
    Array[i] = 333 - i;

}

for( int i = 0; i != 333; ++i){

    CCLOG("Hi %ld", Array[i] );     
}
Run Code Online (Sandbox Code Playgroud)

循环始终打印0 ....

我尝试过很多循环,测试,数组永远不会是数组.它总是只是一个int,或double,或者我尝试的任何类型的数组?

任何问题?

VS2012 cocos2dx helloworld现在被剥夺了一个阵列.Windows 10

Ser*_*sta 6

因为您试图显示%ld格式的双精度.%ld应该只使用很长时间.恕我直言你应该:

两种方法都应该给你正确的显示.