Here is my code..
#include <stdio.h>
struct new {
unsigned short b0 = 0;
unsigned short b1 = 0;
unsigned short b2 = 0;
unsigned short b3 = 0;
unsigned short b4 = 0;
unsigned short b5 = 0;
unsigned short b6 = 0;
unsigned short b7 = 0;
};
int main()
{
printf("Bit Field Example\n");
struct new b; //Seems wrong to me
int result = sizeof(b)/sizeof(*b); //Seems wrong to me
printf("Size: %d\n", result);
return 0;
}
I am using a linux machine to compile the mentioned code. I know that the line below is wrong..
int result = sizeof(b)/sizeof(*b);
But I am not sure about any other technique. First of all, Is it possible to count total number of elements in the structure.? Please give me some idea about how to do it.
Thanks in advance.