well, I want the function or function modification to be used in special cases when the variable may not be an exact bit number divisible by 8(# of bits in a byte).....
Like say a bit field
Code:
struct bitfield{
unsigned first: 1;
unsigned second: 2;
} struct1; // this allocates a struct with 3 bits and no bytes
int main()
{
printf("%d", sizeof(struct bitfield));
}
//Would print either a zero or a one depending on machine,which isn't exact
I want a more exact as the amount of bits allocated in variable
Code:
struct bitfield{
unsigned first: 1;
unsigned second: 2;
} struct1; // this allocates a variable of a struct with 3 bits and no bytes
int main()
{
printf("%d", sizeofbits(struct1)); // a new function, or function modification
}
//prints exactly 3 bits