0
What is wrong in my calculation?
What is output of this code? union uTemp { double a; int b[10]; char c; } u; int main() { printf("%d\n", sizeof(u)); } Double 1*4=4 Int 10*2 =20 Char 1*1=1 Total--25 But the answer has 40. How??
2 ответов
+ 3
int size is 4 so int 10 * 4 = 40
So union considered max value and max value is 40. That's why it is 40.
Note : Size of the union is the the size of its largest field because sufficient number of bytes must be reserved to store the largest sized field
+ 1
Thank you 🅰🅹 🅐🅝🅐🅝🅣





