GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Placement Papers  >  Intel  >  Programming

 Print  |  
Question:  

How much memory will be allocated to this union:

union a

{

char b;

int no:2; (bit field)

}





January 01, 2006 04:42:38 #3
 bndeshmukh1   Member Since: January 2006    Total Comments: 1 

RE: How much memory will be allocated to this union...
 
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
     

 

Back To Question