Varying size of an array

 

At the moment I'm creating an array with 7 entries like this:

string     readline[7];

But I'd like to put the code in a .mqh file and then #include it in many files, with different sizes of the array.

I tried to do this:

int        number = 7
string     readline[number];

but it doesn't compile:

"integer number expected".

Is it possible to do this somehow?

 
alladir:

At the moment I'm creating an array with 7 entries like this:

But I'd like to put the code in a .mqh file and then #include it in many files, with different sizes of the array.

I tried to do this:

but it doesn't compile:

"integer number expected".

Is it possible to do this somehow?

You have to use a dynamic array, and the ArrayResize() function.
 
Excellent, thanks! :D
 

You cant initialize an array with a variable.

Reason: