c - Struct array is printing garbage -
I am having a problem with printing my straight array, it is started like this:
struct matrix token [NBRTE] [12];
Then I try to print it with this code:
printf ("% d", token [0] [0] .state ); (Int q = 0; q & lt; nbrState; q ++) for {for (int r = 0; r Why does it return anyway
-11412982687586982664593143168004196116665039881600950398592587297673016950398176950397984091005908849605884315520000050-100950398592419 And I'm not sure Why. I'm also using the array for loop using the array as well.
while (fscanf (fp, "% d /% d% c", and index, and isolated, inc., And separator) == 3) = 0; I
you said
started it Like
structure matrix token [nbrtte] [12]; But the above announcement is not not started nothing (unless your array is declared with a constant storage period). The garbage will initially include a local array declared in this fashion, apparently what you are printing.
If you want your array initialized , you have to start it yourself, for example, this announcement
structure matrix token [ NBRTE] [12] = {0}; Will start everything with zero, say nbrState is a constant.
If nbrState is not static, you will not be able to use = {...} initializer in the declaration. You must manually assign your array elements to the initial value manually in a circle or some other way.
Comments
Post a Comment