In the main function, I just declare double pointer variables and assign 2 dimensional matrix as below.
int main(){
double **XNODE;
XNODE = (double**)calloc(2,sizeof(double*));
for(int i=0; i<2; i++){
XNODE[i] = (double*)calloc(3,sizeof(double));
}
XNODE[0][0] = 1.0; XNODE[0][1] = -1.0; XNODE[0][2] = -122.0;
XNODE[1][0] = 2.0; XNODE[1][1] = 3.0; XNODE[1][2] = -4.0;
test(*XNODE);
return 0;
and then put the XNODE variable in the below "test" function
void test(double*XNODE)
{
for(int i=0; i<2; i++){
for(int j=0; j<3; j++){
printf("%e ", *(XNODE+3*i+j));
}
}
My expectation is 1 -1 -122 2 3 -4
However the output is as below 1 -1 -122 1.63e-322 2 3
How can I fix this problem??