Hello Everyone,
Somewhere on web, I got this code example of structure (I don't remember but it was something like the snippet below):
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct str
{
unsigned int first:1;
int second:1;
}str;
int main()
{
str exp;
exp.first=1;
exp.second=1;
printf("%d %d\n", exp.first,exp.second);
exp.first=-1;
exp.second=-1;
printf("%d %d\n", exp.first,exp.second);
return 0;
}
Both the printf prints Could you please explain why. This may look because of "signed"(as it is obvious) but I failed to get any explanation for why "exp.second" prints "-1" at first print statement !!
Thanks in advance