Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 7
Why is the output 100 100?
#include <stdio.h> int main() { union{ int i1; int i2; }myVar={.i2=100}; printf("%d %d",myVar.i1,myVar.i2); return 0; }
1 Answer
+ 2
Unions store all of their variables in the same place without offsets.