fork download
  1. struct example
  2. {
  3. int a;
  4. double b;
  5. int c;
  6. };
  7.  
  8. #include <iostream>
  9. #include <cstddef>
  10.  
  11. int main()
  12. {
  13. std::cout << offsetof(example, a) << '\n';
  14. std::cout << offsetof(example, b) << '\n';
  15. std::cout << offsetof(example, c) << '\n';
  16. std::cout << sizeof(example) << '\n';
  17. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
0
4
12
16