I'm calling a function which returns a `3D array`. The problem is that if I declare the array inside the function it returns a dangling pointer as the execution of the program goes out of the scope of the variable. But when I declare the array outside the function, it gives `Error:'array' was not declared in this scope`. How should I declare the array? It returns integer type.

```
int arr[x][y][z];
int func(list of parameters)
{
  //code
  return arr;
}

int main()
{
  int arr2[x][y][z];
  arr2 = func(list of parameters);
  return 0;
}

```