I am generating 3 nxn sized magic squares (Where n is an odd number between 3 and 15), and want to pass the 2d arrays they are stored in to this function:
void printSquare(int n, int square[n][n], int b){
cout << "Magic Square #" << b << " is:\n";
for(int i=0; i<n; i++)
{
for(int j=0; j<n; j++)
printf("%3d ", square[i][j]);
printf("\n");
}
}
The arrays are passed to the function like this:
printSquare(n, magicSquare, 1);
However, no matter how I try to change it to get the function to accept the 2d array with undefined size, I keep getting errors like "candidate function not viable: no known conversion from 'int [n][n]' to 'int (*)[n]' for 2nd argument". How can I fix this so that I can use the 2d array in my function?