Hi,
the code below ends with EXC_BAD_ACCESS when I run it. I also get a warning message from the compiler telling me that array_s is an incompatible pointer type when calling the fill_array function. Where is the problem? If I write similar code working with one-dimensional array, it functions properly.
Code:
#define ROWS 3
#define COLUMNS 4
void fill_array(int **arr, int rows, int columns)
{
int i, j;
for (i = 0; i < rows; i++)
for (j = 0; j < columns; j++)
arr[i][j] = columns * i + j;
}
int main (int argc, const char * argv[])
{
int array_s[ROWS][COLUMNS];
fill_array(array_s, ROWS, COLUMNS);
return 0;
}