Tuesday, October 22, 2013

2d array call in a function

Newsgroup: comp.lang.c++

Subject: 2d array call in a function

From: axcytz@...

Date: Tue, 22 Oct 2013 18:15:10 -0700 (PDT)



Hi all,



I have a 2d array that I declared as:



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:



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!







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?113596-2d-array-call-in-a-function&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

No comments:

Post a Comment