468,458 Members | 1,859 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,458 developers. It's quick & easy.

What does this (unusual?) structure definition mean?

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
3 3284

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

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
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.

Similar topics

12 posts views Thread by Helmut Jarausch | last post: by
20 posts views Thread by Steven T. Hatton | last post: by
100 posts views Thread by E. Robert Tisdale | last post: by
21 posts views Thread by Helge Jensen | last post: by
669 posts views Thread by Xah Lee | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.