I have the following function
void initBoard(int * board[BOARD_ROWS][BOARD_COLS]){
int z = 0;
for( z = 0; z<10; z+=1){
int l;
for( l = 0; l<10; l+=1){
board[z][l] = 0;
}
}
}
and from main i call it like
int plBoard[10][10];
initBoard(&pcBoard);
when compiling it works but i get a warning saying: warning: passing argument 1 of ‘initBoard’ from incompatible pointer type. array is an integer and and function expects a int pointer i am passing the address of int. What is wrong with it?
Apart from the obvious typo in your question (the definition of
plBoardbut the use ofpcBoard), you don’t need to pass arrays with the address-of operator (&), since they’re converted to addresses automatically.But your
incompatible typeproblem is caused by the use of:which is actually a 2d array of
intpointers (technically an array of array of pointer toint), not integers as you expected.You should use: