I'm quite new to C programming and am running in to a strange problem. I have a global variable tri which is a struct (tri_fact) with a couple of members. Two of these members (tri.Q and tri.R) are in turn of a different kind of struct (dense_mat) for dense matrices.
I have a function to initialize some of these dense matrices to zero. The problem I'm having is that one of these matrices has junk values when the initialization function is exited. Right before exiting, however, everything looks good.
struct tri_fact tri;
void init_func(){
/*do some initializations*/
/*tri.Q and tri.R looks good*/
}
void func(){
init_func();
/* tri.R looks good, but tri.Q is filled with junk */
}
Am I missing something fundamental?