So I have this code where I'm trying to define a dynamic matrix with n*n size. It turns out that, instead of the output printing the value for G, it prints 0 instead. Any idea why?
#define G 6.67408e-11
typedef struct matrix
{
double mass;
double cmx;
double cmy;
}MATRIX;
MATRIX **mtr;
void main(int argc, char** argv){
const long n = atoi(argv[1]);
mtr = (MATRIX**)calloc(n,sizeof(MATRIX*));
for (int i=0; i<n; ++i)
{
mtr[i]=(MATRIX*)calloc(n,sizeof(MATRIX));
}
mtr[0][0].cmx=G;
printf("%f\n", mtr[0][0].cmx);
}