Work from the outside. You know that you have an array of 5 things to initialize:
mystruct foo[5] = { X, X, X, X, X };
where X is the backup for mystruct type mystruct . So now we need to figure out what each X looks like. Each mystruct instance has two elements: somearray and somevar , so you know that your initializer for X will be structured as
X = { Y, Z }
Substituting back into the original ad, we get
mystruct foo[5] = { { Y, Z }, { Y, Z }, { Y, Z }, { Y, Z }, { Y, Z } };
Now we need to find out what each Y looks like. Y corresponds to the initializer for the 3x2 array from int . Again, we can work from the outside. You have an initializer for a 3 element array:
Y = { A, A, A }
where each element of the array is a 2-element int array:
A = { I, I }
Returning to Y, we get
Y = { { I, I }, { I, I }, { I, I } }
Substituting this back into X, we get
X = { { { I, I }, { I, I }, { I, I } }, Z }
which now gives us
mystruct foo[5] = { { { { I, I }, { I, I }, { I, I } }, Z }, { { { I, I }, { I, I }, { I, I } }, Z }, { { { I, I }, { I, I }, { I, I } }, Z }, { { { I, I }, { I, I }, { I, I } }, Z }, { { { I, I }, { I, I }, { I, I } }, Z } };
Since Z is a stand for an integer, we no longer need to split it. Just replace I and Z with real integer values ββand you are done:
mystruct foo[5] = { {{{101, 102}, {201, 202}, {301, 302}}, 41}, {{{111, 112}, {211, 212}, {311, 312}}, 42}, {{{121, 122}, {221, 222}, {321, 322}}, 43}, {{{131, 132}, {231, 232}, {331, 332}}, 44}, {{{141, 142}, {241, 242}, {341, 342}}, 45} };