-
Can this be done!
Away from a compiler right now but I was thinking about the following code. The overall result will be to print the bit reprsentation of input.
Thx
[code]
struct n_bits {
unsigned int a:1;
unsigned int b:1;
unsigned int ...
unsigned int p:1;
}nbits;
nbits = getchar();
-
Not like that it can't - you would have to make the struct part of a union, with the other member of the union being an int.
Besides, you're assuming a specific number of bits in a char/int/whatever
It's much better to use a loop and CHAR_BIT from limits.h