array size as a variable

 

Hi forum, quick question here.

i am trying to do this:

int size = 500;
double some_array[size];

but i am getting compilation error "size - integer number expected"

is there a way i can do this at mql4?

thank you very much.

oX.

 
oxarbitrage:

Hi forum, quick question here.

i am trying to do this:

int size = 500;
double some_array[size];

but i am getting compilation error "size - integer number expected"

is there a way i can do this at mql4?

thank you very much.

oX.


Have a look at ArrayResize() to do it dynamically. In your declaration, size would need to be a constant defined and known at compile time, not run time..

Regards, Paul.

 
int size = 500;
double some_array[]; ArrayResize(some_array, size);
 

thank you paul and WHRoeder, ArrayResize worked perfect for me :)

thanks again