fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5. struct bitfield{
  6. unsigned a:5;
  7. unsigned c:5;
  8. unsigned b:6;
  9. } bit = {1,3,3};
  10.  
  11. char *p = (char*)&bit;
  12. printf("%d\n",*p);
  13. p++;
  14. printf("%d\n",*p);
  15. // I assumed that the bits are laid out in the below order in the memory. Spaces are just for clarity
  16. // Also, I asumed that the 'char' will take 8 bits. But I can't seem to understand the output.
  17. //00001 00011 000011
  18. return 0;
  19. }
  20.  
  21.  
  22.  
Success #stdin #stdout 0s 2292KB
stdin
Standard input is empty
stdout
97
12