Advertisement
foreverfugazi

WHY??

Jun 7th, 2023
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. #include<stdio.h>
  2. union X
  3. {
  4.     int i;
  5.     int j;
  6.     double k;
  7. }; // ; compulsory
  8. struct Y
  9. {
  10.     int i;
  11.     int j;
  12.     double k;
  13. };
  14. int main()
  15. {
  16.     printf("sizeof X is %lu\n",sizeof(union X));
  17.     union X x1;
  18.     x1.i = 23;
  19.     x1.j = 23;
  20.     x1.i = 49;
  21.     printf("%d %d\n",x1.i, x1.j);
  22.     printf("sizeof Y is %lu\n",sizeof(struct Y));
  23.     return 0;
  24. }
Tags: confused why
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement