invalid index value error!!

 
int n=100;
double a[n];

Hi, can anybody say why thee is an "invalid index value" error?

 
https://www.mql5.com/en/docs/basis/types/dynamic_array

See Static Arrays

Correct code:

void OnStart()
  {
//---
   double a[100];
  }

It is expecting a constant value 100 instead of a variable n.

Documentation on MQL5: Language Basics / Data Types / Dynamic Array Object
Documentation on MQL5: Language Basics / Data Types / Dynamic Array Object
  • www.mql5.com
Maximum 4-dimension array can be declared. When declaring a dynamic array (an array of unspecified value in the first pair of square brackets), the compiler automatically creates a variable of the above structure (a dynamic array object) and provides a code for the correct initialization. Static Arrays When all significant array dimensions are...
 
Zee Zhou Ma:
https://www.mql5.com/en/docs/basis/types/dynamic_array

See Static Arrays

Correct code:

It is expecting a constant value 100 instead of a variable n.

Thanks!

Reason: