我正在尝试以下代码:
void OnInit()
{
int i = 0;
string d[];
while(i < 2)
{
ArraySetAsSeries(d,true);
for (int j=0; j<5; j++)
{
if(MathMod(j,2)==0 && i==0)
d[j] = "even";
else if(MathMod(j,2)==0 )
d[j] = "even without i zero";
else
d[j] = "odd";
}
i++;
}
}我愿意在测试中获得输出。但是我得到了以下错误:
2018.03.23 14:51:20.005欧元兑美元,M1 (MetaQuotes-Demo):基于实数生成
ticks
2018.03.23 14:51:20.006 EURUSD,M1: testing of Experts\testing lines and trdae.ex5 from 2018.02.01 00:00 to 2018.02.20 00:00 started
2018.03.23 14:51:20.050 2018.02.01 00:00:00 array out of range in 'testing lines and trdae.mq5' (61,2)
2018.03.23 14:51:20.051 OnInit critical error请帮我把这个去掉,并在我愿意打印的时候打印数组。
发布于 2018-03-23 22:44:02
在向数组中插入数据之前,必须明确指出数组的大小。
使用ArrayResize(d,5);,它就会工作。
https://stackoverflow.com/questions/49446235
复制相似问题