fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. union u1 {
  5. char a[9];
  6. char b[3];
  7. };
  8. union u2 {
  9. //char a[3];
  10. //char b[9];
  11. int c;
  12. };
  13. int main() {
  14. // your code goes here
  15. int i;
  16. printf("size of int = %d\n", sizeof(i));
  17.  
  18. u1 union1;
  19. printf("size of u1 = %d\n", sizeof(u1));
  20.  
  21. u2 union2;
  22. printf("size of u2 = %d\n", sizeof(u2));
  23. return 0;
  24. }
Success #stdin #stdout 0s 4448KB
stdin
Standard input is empty
stdout
size of int = 4
size of u1 = 9
size of u2 = 4