Wrong description in documentation about multidimensional arrays

 

Hi

The article about multidimensional arrays has a mistake.

https://www.mql5.com/en/articles/567



It should be the other way around.

The first index contains the number of ROWS.

The second index contains the number of COLUMNS.

double Variable[10][3] ==> double Variable[3][10]
MQL5 Programming Basics: Arrays
MQL5 Programming Basics: Arrays
  • www.mql5.com
Arrays are an integral part of almost any programming language along with variables and functions. Many novice programmers are often afraid of arrays. It sounds strange but it is true! I can assure you that they are not scary at all. In fact, arrays are similar to regular variables. Without going into detail about the notation peculiarities...
 

You are correct. The first index is rows the second is columns. If you want to see for yourself:

void OnStart()
{
   int matrix[3][3] = {
      {1,2,3},
      {4,5,6},
      {7,8,9}
   };
   printf("assert row 3 col 1 is 7 [%s]",
      string(matrix[2][0] == 7)
   );
}

//assert row 3 col 1 is 7 [true]