Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

struct definition with ':' after name of the variable

I’m reading about structs in C and I came across some interesting declaration that I don’t know what does is mean. The declaration goes as follows:

typedef struct name{
   int x :1;
}name;

what does line ‘int x :1;’ mean ? is 1 the default value of x?

Would appreciate help! Thanks

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It specifies the number of bits to use for that field. It is called "bit field".

Check this: https://en.cppreference.com/w/cpp/language/bit_field

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading