fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A
  5. {
  6. int8_t a; //only 4 bit
  7. int16_t b; //only 10 bit
  8. };
  9.  
  10. struct B
  11. {
  12. int8_t a:4; //only 4 bit
  13. int16_t b:10; //only 10 bit
  14. };
  15.  
  16. struct C
  17. {
  18. int16_t a:4; //only 4 bit
  19. int16_t b:10; //only 10 bit
  20. };
  21.  
  22. int main()
  23. {
  24. cout<<sizeof(A)<<endl;
  25. cout<<sizeof(B)<<endl;
  26. cout<<sizeof(C)<<endl;
  27. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
4
2
2