Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Colon operator in a variable declaration statement inside struct [duplicate]

Tags:

c

Possible Duplicate:
What does 'unsigned temp:3' means

struct sample{
    int x    :2;
    char y   :4;
};

What does the colon operator do in the above code?

like image 683
subbu Avatar asked May 03 '26 14:05

subbu


1 Answers

It is used to specify bit fields. The size of the field is given in bits. The layout is compiler-specific.

like image 188
Jonathan Leffler Avatar answered May 05 '26 05:05

Jonathan Leffler