fork download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. struct s
  5. {
  6. double a;
  7. char ch;
  8. };
  9.  
  10. struct s2
  11. {
  12. char c;
  13. double b;
  14. };
  15.  
  16. struct s3
  17. {
  18. char ch;
  19. int a;
  20. };
  21.  
  22. struct s4
  23. {
  24. char character;
  25. double d;
  26. int a;
  27. };
  28.  
  29.  
  30. int main()
  31. {
  32. s obj;
  33. s2 obj2;
  34. cout<<sizeof(obj);
  35. cout<<endl<<sizeof(obj2);
  36. cout<<endl<<sizeof(s3);
  37. cout<<endl<<sizeof(s4);
  38. return(0);
  39. }
  40.  
Success #stdin #stdout 0s 2724KB
stdin
Standard input is empty
stdout
12
12
8
16