By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,750 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,750 IT Pros & Developers. It's quick & easy.

What does this (unusual?) structure definition mean?

P: n/a
Hi,

What exactly does the following code mean? More specific, what are the
colons for? Is this some kind of way to initialize the structure
members?

struct somestruct
{
unsigned char a:1;
unsigned char b:1;
unsigned char c:1;
};

Regards,

Frederiek

Jul 11 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Frederiek wrote:
Hi,

What exactly does the following code mean? More specific, what are the
colons for? Is this some kind of way to initialize the structure
members?

struct somestruct
{
unsigned char a:1;
unsigned char b:1;
unsigned char c:1;
};

Regards,

Frederiek
Look in your favorite reference for bitfields.

Jul 11 '06 #2

P: n/a

Frederiek wrote:
Hi,

What exactly does the following code mean? More specific, what are the
colons for? Is this some kind of way to initialize the structure
members?

struct somestruct
{
unsigned char a:1;
unsigned char b:1;
unsigned char c:1;
};

Regards,

Frederiek
It's declaring a bit field.

-Brian

Jul 11 '06 #3

P: n/a
Frederiek <fd*****@hotmail.comwrote:
What exactly does the following code mean? More specific, what are the
colons for? Is this some kind of way to initialize the structure
members?

struct somestruct
{
unsigned char a:1;
unsigned char b:1;
unsigned char c:1;
};
It's called a bit-field. a, b and c are each one bit (that is what
the number after the colon means).

regards
--
jb

(reply address in rot13, unscramble first)
Jul 11 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.