Currently I am working on c and facing a confusion regarding signed int in structure and here I have given the example:
#include <stdio.h>
#include <string.h>
struct {
signed int age : 4;
} Age;
int main( ) {
Age.age = -8;
printf("Age.age : %d\n", Age.age );
return 0;
}
Here, I already have described the size of bits which int will occupy while storing the value. here I am assigning value -8 to age. so it will store value like 1000 for 8 and for -8 it should store like 11000 where left 1st bit is known as sign bit. So if int age have to store -8 it must have 5 bits but while I compile the given example it is not giving error and displays an output.
Please help me with my issues.