Download MetaTrader 5

Problem with arrays

To add comments, please log in or register
Publish your application in the Market - 7 million potential clients will see it
Paul Anscombe
3996
Paul Anscombe 2013.02.14 13:16 

I need to create a two dimensional array dynamically, that is to say I do not know in advance what size the array needs to be.

Therefore I would want to create an array like this (below) where iSizeA & iSizeB are intergers with the required sizes.   

   double   dInputData[iSizeA][iSizeB];

 However, it seems that MQL5 will not allow this and you must declare the array with a static size for the second element.

ArrayResize only works on the first element of an array.

So how can I have 2nd dimension that is variable in size?  this seems to be a short coming as sometimes I will only need a few elements in the 2nd dimension and other times many thousands, if I set it to many thousands statically, it will not only use lots of memory needlessly most of the time but may still not be enough on occasions and cause the program to fail.

 

any ideas? 

 

phi nuts
2184
phi nuts 2013.02.15 09:32  

Been asked before Dynamic- 2 dimension array

Guess you have to create 2 dynamic arrays :( 

To add comments, please log in or register