How much memory will be allocated to this union:union a{char b;int no:2; (bit field)}

Showing Answers 1 - 3 of 3 Answers

non-name

  • Sep 12th, 2005
 

3 bit

  Was this answer useful?  Yes

asadullah ansari

  • Dec 19th, 2005
 

Size of a union is the size of one of the data types which resides in union, whose is the largest between them so it's size is ONE BYTE.

  Was this answer useful?  Yes

bndeshmukh1

  • Jan 21st, 2006
 

hi, size of a union is size of largest data type among its members ...so size of union a is 4 bytes.Even if int no is type bt-field the sizeof union will remain 4 bytes as sizeof(int) = 4.now int no:2 means value for "no" wil be 2-bit wide i.e. either 00->0, 01->1 , 10->2 or 11->3 that is all--bhalchandra

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions