2

can anyone tell me, what is happening in this code. I tried to search a lot of places but couldn't understand what exactly is the commented part of the code doing.

#include<stdio.h>

struct XYZ {
    //int a:6; this one.
    char s; 
}structure;

int main() {
     printf("%lu",sizeof(structure)); 
     return 0;
}

I am getting the output as 4.

ncst
  • 187
  • 1
  • 1
  • 10

1 Answers1

4

That line is commented out. It doesn't do anything.

If it wasn't commented out, it would mean that the size of int a is limited to 6 bits only. It's useful for bit-fields inside of a structure.

viraptor
  • 33,322
  • 10
  • 107
  • 191