[Solved] Passing 2D array by value doesn’t work


to prevent func1 from being changed, change it to a const pointer.

void func1(const int (*myArray)[3])
{
    int i, j;
    int ROWS=3;
    int COLS=3;

     for (i=0; i<ROWS; i++)
     {
         for (j=0; j<COLS; j++)
         {
            // myArray[i][j] =3; //compilation error, is now const
            cout <<" "<<myArray[i][j];  
         }
     }
}

2

solved Passing 2D array by value doesn’t work