Let's say I have struct S:
typedef struct
{
int x;
int y;
} S;
Then:
S s; // s is uninitialized here.
And:
S s = {}; // s is initialized (zeroed) here.
Now let's say I have struct T:
typedef struct
{
S s1;
S s2;
} T;
And I initialize it like this:
T t = {}; // is t completely initialized?
I'm just guessing that t.s1.x
can contain a random value, right?
Do I have to write:
T t = {{}, {}};
Is it necessary to have t.s1
and t.s2
initialized / zeroed?
Then, if I write:
int a[8];
Is it 8 zeroes, or 8 random values, that most likely are zeroes?
Again, I'm guessing I should write
int a[8] = {};
... to have 8 certain zeroes, but I'm not sure.
What about:
T[8] = {};
Is it 8 initialized T
s, or 8 uninitialized / random T
s?
How do you properly initialize / zero such nested structs and arrays?
By initialization I mean just having zeroes everywhere.