Int bit3:4 will be read as lower order 4 bits of bit3 and this will be treated as int (signed). Thus lower order bit of bit3 which is 2, are 0010 which is 2 try with 1) int bit3:2, output will be -2 2) unsigned int bit3:2, output will be 2.
I hope it is cleared now On 8/9/11, Rohit Srivastava <access2ro...@gmail.com> wrote: > #include<stdio.h> > #include<conio.h> > > int main() > { > struct value > { > int bit1:1; > int bit3:4; > int bit4:4; > }bit={1,2,2}; > printf("%d %d %d\n",bit.bit1,bit.bit3,bit.bit4); > getche(); > return 0; > } > the above code gives output : -1 2 2 > any idea why??? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Sent from my mobile device Sanjay Ahuja, Analyst, Financing Prime Brokerage Nomura Securities India Pvt. Ltd -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.