问题
How to access entire structure members in C.Means I want to take all the data of variables in structure.
struct data
{
char a:1;
char b:2;
char c:3;
char d:1;
} arr;
I can access individual members by using . operator.But i need to access all members in that structure.Colud you please tell me how to do.
回答1:
As suggested make an union of the whole data and of the bitfield structure.
union
{
char Whole;
struct data
{
char a:1;
char b:2;
char c:3;
char d:1;
} arr;
} MyData;
来源:https://stackoverflow.com/questions/35934375/bitfields-in-c-programming-language