+ 6
Why is the size of union here 40?
#include <stdio.h> union uTemp{ double a; int b[10]; char c; }u; int main() { printf("%d\n",sizeof(u)); return 0; }
3 Respostas
+ 3
Size of union = Size of largest data type.
Here the largest data type is array
int b[10]
whose size is 4x10 = 40 (size of int x number of elements)
+ 2
We know that 4 is a int no and here it is give that int b[10] so the result is found 4×10=40 and 10 =size of array
+ 1
40 bytes