Download MetaTrader 5
To add comments, please log in or register
Find out how to install MetaTrader on Linux
cryptex23
268
cryptex23 2015.08.17 04:07 

Hello, I would be grateful if someone could help me handle this Array Out of Size Error.

 


double b [200][1];
int OnInit()
  {

for(j=0;j<=param-1;j++)
  {

  b[j][1]=(summation/product); //correct formula 
  
  }
Keith Watford
Moderator
7985
Keith Watford 2015.08.17 04:56  
double b [200][1];
int OnInit()
  {

for(j=0;j<=param-1;j++)
  {

  b[j][1]=(summation/product); //correct formula 
  
  }

 First of all, you should code to make sure that the loop is exited if j>=199 as we don't know what value param is.

The 2nd dimension is sized [1], so it only has one index and that must be 0

b[j][1] does not exist as the 2nd dimension can only be 0 

cryptex23
268
cryptex23 2015.08.17 18:07  
GumRai:

 First of all, you should code to make sure that the loop is exited if j>=199 as we don't know what value param is.

The 2nd dimension is sized [1], so it only has one index and that must be 0

b[j][1] does not exist as the 2nd dimension can only be 0 

Yep, I have specified param as 200. What!!! even when assign column values the values begin from 0??? If i am understanding it correctly you are saying for double b[10][1] the correct way to assign is b[i][0]??? and not b[i][1]? :O
Keith Watford
Moderator
7985
Keith Watford 2015.08.17 23:28  
cryptex:
Yep, I have specified param as 200. What!!! even when assign column values the values begin from 0??? If i am understanding it correctly you are saying for double b[10][1] the correct way to assign is b[i][0]??? and not b[i][1]? :O

yes, and always make sure that i is less than 10 (in this case)

Why use a 2 dimensional array when you are only using 1 element in the 2nd dimension? 

cryptex23
268
cryptex23 2015.08.18 04:10  
GumRai:

yes, and always make sure that i is less than 10 (in this case)

Why use a 2 dimensional array when you are only using 1 element in the 2nd dimension? 

 

 

Habituated to code in MATLAB. Could you please tell how do i write the 1d array? Just b[10]?
Keith Watford
Moderator
7985
Keith Watford 2015.08.18 05:15  
cryptex:
Habituated to code in MATLAB. Could you please tell how do i write the 1d array? Just b[10]?
yes
/
To add comments, please log in or register