2d array call in a function

Hi all,

I have a 2d array that I declared as:

1
2
3
int array[3][3] ={{1,2,3},{1,3,5},{3,2,5}};
int InitialArray[3] = {..};
int Result;



I also use this in a function:


1
2
3
4
5
6
7
8
int Calculate(int myarray[], int array[][3], int result)
{
    for(int i=0; i<3 ;i++)
    {
       for(int j=0; j<i+1 ;j++)
         result += array[myarray[i]][myarray[j]];
    }
}


In main, I call it as


Calculate(InitialArray, array, Result);

I get some errors because of the 2d array in function. How should i fix this?

expected primary-expression before â]â token
array bound is not an integer constant


Thanks in advance!
Last edited on
The code you've posted shouldn't result in that error.

Although, it should result in a few warnings (such as Calculate not returning a value and using the uninitialized variable Result.)

Are you sure this is the exact code, and that the error message is actually referring to the line you're pointing us to?
Topic archived. No new replies allowed.