Array problem

hi i am new in c++, my problem is pass a multi dimentional array to a function


int hitemp (int temp[int][int]); //function diclaration

int main()

{

int rows=3;
int columns=4;

int seasontemp[rows][columns]={
{24,35,17},
{25,67,44},
{15,34,22},

};

cout<<"heigest temperature is"<<hitemp(int temp[rows][columns]);

return 0;
}



int hitemp (int temp[rows][columns])
{
int highest = 0;
for (register i = 0; i < rows; ++i)
for (register j = 0; j < columns; ++j)
if (temp[i][j] > highest)
highest = temp[i][j];
return highest;
}


You have three errors:
int hitemp (int temp[int][int]); //function diclaration
you need to specify the size of the array int hitemp (int temp[3][4])
(see Arrays as parameters http://www.cplusplus.com/doc/tutorial/arrays/ )

1
2
3
4
int hitemp (int temp[rows][columns])
{
   //...
}
Same as in the declaration

cout<<"heigest temperature is"<<hitemp(int temp[rows][columns]);
You want to pass seasontemp so it should be hitemp(seasontemp)


Topic archived. No new replies allowed.