I am trying to globally define a multidimensional array. The dimensions will ultimately depend on some other computations. Here I'll just consider n and B to be 5 but I place them inside function2 to stress that the dimensions are not known initially. At some point I'll also need to duplicate this array. The code below gives the error **Subscripted value is not an array, pointer, or vector** on the line where I'm printing the array2 entries. How can I fix this error and is there anything else I need to change to accomplish this?

```
int n,B;
double ** array;
double ** array2;

void function(){
    double array[n][B][n];
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= B; j++){
            for(int k = 1; k <= n; k++){
                array[i-1][j-1][k-1] = i*j*k;
            }
        }
    }
}

void function2(){
    n=5;
    B = 5;
    function();
    array2 = array;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= B; j++){
            for(int k = 1; k <= n; k++){
                printf("%lf",array2[i-1][j-1][k-1]);
            }
        }
    }
}

int main(){
    function2();
    return 0;
}

```