I have a two-dimensional array, and I pass it to a function to perform certain operations. I would like to know the right way to do this ...
#define numRows 3 #define numCols 7 #define TotalNum (numRows*numCols) int arr[numRows][numCols] = {{0,1,2,3,4,5,6}, {7,8,9,10,11,12,13},{14,15,16,17,18,19,20}}; void display(int **p) { printf("\n"); for (int i = 0; i< numRows;i++) { for ( int j = 0;j< numCols;j++) { printf("%i\t",p[i][j]); } printf("\n"); } } int main() { display(arr); }
The error message appears:
'display': cannot convert parameter1 from 'int' to 'int*'
Is this the correct way to pass a two-dimensional array into a function? If not, what is the right way?
c
lakesh Feb 25 '12 at 18:20 2012-02-25 18:20
source share