fork download
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3.  
  4. struct test{
  5.  
  6. bool opaque : 1;
  7. unsigned int fill_color : 3;
  8. unsigned int : 4;
  9. bool show_border : 1;
  10. unsigned int border_color : 3;
  11. unsigned int border_style : 2;
  12. unsigned int : 2;
  13. };
  14.  
  15.  
  16. int main(void)
  17. {
  18. struct test Test = {0};
  19. int i;
  20. printf("%zu\n", sizeof(Test));
  21.  
  22. unsigned char* p;
  23. p = (unsigned char*)&Test;
  24. for(i=0; i<sizeof(Test); ++i)
  25. {
  26. printf("%02x", *p);
  27. ++p;
  28. }
  29. printf("\n");
  30.  
  31. Test.opaque = true;
  32.  
  33. p = (unsigned char*)&Test;
  34. for(i=0; i<sizeof(Test); ++i)
  35. {
  36. printf("%02x", *p);
  37. ++p;
  38. }
  39. printf("\n");
  40.  
  41. Test.fill_color = 3;
  42.  
  43. p = (unsigned char*)&Test;
  44. for(i=0; i<sizeof(Test); ++i)
  45. {
  46. printf("%02x", *p);
  47. ++p;
  48. }
  49. printf("\n");
  50.  
  51. return 0;
  52. }
  53.  
Success #stdin #stdout 0s 4264KB
stdin
Standard input is empty
stdout
4
00000000
01000000
07000000