It hardly has anything to do with my question. It talks about initialization instead of declaring and says nothing about dynamic 2-dimension arrays.
Try this
int qwerty [][2];
It's 2 dimensional array, the first bracket tell the array from left to right. the second bracket tell the array from top to bottom, and you have to specify how many of them - how many element of them.
Try this
It's 2 dimensional array, the first bracket tell the array from left to right. the second bracket tell the array from top to bottom, and you have to specify how many of them - how many element of them.
Thanks, but that they only first dimension will be dynamic. I need both dimensions to be dynamic as I don't know the sizes beforehand.
- 2010.11.17
- investeo
- www.mql5.com
You can find an example in one of my articles - look at https://www.mql5.com/en/articles/196 (CChartEditTable implementation)
Hi, I had the same problem, I'm just learning and I don't understand completely the solutions given, but this idea worked for me. I hope to help.
struct dynamic_2D { double col[]; }; dynamic_2D u[]; int nrow=10; int ncol=20; ArrayResize(u,nrow,0); for(int i=0; i<=nrow-1; i++) { ArrayResize(u[i].col,ncol,0); ArrayInitialize(u[i].col,0); }
How do I declare dynamic 2-dimension arrays?
The following code generates error:
Hello Andriy,
The multidimensional arrays are dinamic "ONLY" at the first dimension...
Take a look at the article about arrays...
Hope it helps...
If you need dinamic on more than 1 dimension, you will need to create a code with "for example" struct... Like autotradefx showed up this...

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
How do I declare dynamic 2-dimension arrays?
The following code generates error:
int arr[][];