Can a static array that is declared in main
be initialized/mutated in a function?
I tried the code below but it returns a seg fault.
void initialize(int **p, int a, int b)
{
int i, j;
for(i=0; i<a; ++i) {
for(j=0; j<b; ++j)
p[i][j] = j;
}
}
int m = 5;
int n = 5;
int arr[m][n];
int **A = &arr[0][0];
initialize(A, m, n);
EDIT:
I found a good explanation of this issue here: