Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6
Since "arr" is an array of two-dimensional arrays, it will take two numbers from the initializer list and use them to construct a two-dimensional array, while leaving the others in the list. Therefore, it will construct the pairs { 1, 2 }, { 3, 4 }, { 5, 6 } and { 7, 8 } before only 9 is left inside the list. Since an array must contain the same type of element, the last element has to be a two-dimensional array as well, where the first elememt equals 9. According to C, elements that are not initialized explicitly from an initialization list become zero-initialized, thus the last pair will come out as { 9, 0 }. This makes for a total of 5 * 2 integers with a size of 4 byte, resulting in 10 * 4 = 40 as the final size of the array. The following page explains array initialization in C in great detail while showing some examples: https://en.cppreference.com/w/c/language/array_initialization
31st Oct 2020, 9:15 AM
Shadow
Shadow - avatar