<hu-axiang> wrote in message
news:42***********************@news.optusnet.com.a u...
What is the function of ":" and followed number (2 or 1) in the followin
structure?
typedef struct {
unsigned int A : 2;
unsigned int B : 2;
unsigned int C : 2;
unsigned int D : 2;
unsigned int E : 1;
} ASampleStruct;
Those are "bit fields". They specify how many bits of the struct are
actually allocated for each of the members. They're useful sometimes when
you need a specific number of bits for your data. Read up about how to use
them in your favorite book.
By the way, you're using C-style notation for your struct definition, which
is kind of overkill. C+ structs are defined more simply, like this:
struct ASampleStruct
{
// add members here
};
-Howard