fork download
  1. #include <iostream>
  2.  
  3. struct S
  4. {
  5. uint32_t a : 4;
  6. uint32_t b : 8;
  7. uint32_t c : 16;
  8. };
  9.  
  10. int main()
  11. {
  12. S s = { 1, 2, 3 };
  13. std::cout << sizeof(s) << ", " << s.a << s.b << s.c << std::endl;
  14. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
4, 123