#include <stdio.h>
struct temp{
unsigned int zero_bit : 1;
unsigned int first_bit : 1;
} ;
// struct temp_1{
// unsigned int zero_bit : 0;
// unsigned int first_bit : 0;
// } ; // Code fails
int main() {
struct temp a1;
printf("%d", a1.zero_bit); // returns 0
return 0;
}
My question is, why does temp1 struct fail but not temp struct, considering they are both initialized to 0. Why does the compiler give me the false hope that zero_bit has been initialised to a value of 1 when it has been initialized to a value of 0 in reality?
1