I have global 3D arrays defined as
double*** arr;
in a file common.c
I have the declaration
extern double*** arr;
in a file common.h
Now when I am initializing this array dynamically at runtime, I am running into a segmentation fault I executed the code
exs =malloc(sizeof(double)*nx*ny*nz);
where nx,ny and nz are known at runtime prior to executing this statement.
But when i try to initialize this array as
for(i=0;i<nx;i++)
for(j=0;j<ny;j++)
for(k=0;k<nz;k++)
arr[i][j][k]=0.0e0;
I get a segfault.
What am I doing wrong ?
<instead of<=