maybe
int A[1];
Read in the reference about arrays - their size has to be set initially!!
You are trying to fill an array with no elements. You can either declare a static array with a set array size
int arr[1]; arr[0] = 5;
or dynamic array with initialization list or resize
int arr[]; ArrayResize(arr,1); arr[0] = 5; OR int arr[] = {1,2,3,4,5};
or you can use one of the collections from the standard lib
#include<Arrays\ArrayInt.mqh> CArrayInt arr; arr.Add(5);
Guys,
thank y'all for your feedback. I guess I didn't express the problem clearly. I am trying to define a dynamic integer array and I'm assigning values to it in a for loop. For some reason the array sizes dont match so I get this array out of range error. What I was trying to do was to check the assignment process was completed at each iteration to find which iteration is giving me the out of range error. However, weird thing is, it doesn't ran even the first iteration. I was wondering if that is what happens in these cases by default.
thanks alot
You'll find everything you need to solve you problem in the reference (Editor, F1)!
You are trying to fill an array with no elements. You can either declare a static array with a set array size
or dynamic array with initialization list or resize
or you can use one of the collections from the standard lib
Thanks a lot for your input. Can I just create a dynamic array and fill it with numbers later on in the code?
int A[];
for (int i=0;i==50;i++)
{A[i]=i;}
well thanks for nothing. I know that! and trust me,
Really? So why don't just modify this example of ArrayGetAsSeries?
... for(int i=start_index;i<rates_total;i++) buffer[i]=MathAbs(first[i]-second[i]); ...
Just start from the fact that almost no question hasn't answered several times either here (search at the corner top, right) or elsewhere (google)!!
I wan to show you a faster way to find an answer!
Your first post was was 24 h ago, the answer in the reference took me less than 2 minutes to find!
It does and F1 is a very good way to find an answer!
Thanks a lot for your input. Can I just create a dynamic array and fill it with numbers later on in the code?
int A[];
for (int i=0;i==50;i++)
{A[i]=i;}
You've been given the answer by nicholsen in the 3rd post!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys,
I am having a bizarre problem. A simple expression is giving me a consistent error. Could anyone give me a hint what is wrong?
//--- preprocessor
.
.
.
int A[];
//---- in OnInint() section
{
A[0]=5;
Print(A[0]);
}
ERROR: array out of range
Thanks a lot,