CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS LANGUAGES C DETAILS
Question :
Whats is structure padding?Say a given structure
Struct{
int a;
char c;
float d;
}
the size of structure is 7 here.
But structure padding is done what will be the size of the struct?Will it change and how?How to avoid this?is it necessary?


Category C Interview Questions
Rating (5.0) By 1 users
Added on 7/17/2006
Views 757
Rate it!
Answers:

Integers and floats :compilers will try to place these variables at addresses which are in multiples of 2 or 4(in 16-bit system) now in this case 1 byte can be padded...we can store integers and floats at start to avoid padding



answer is 12.because the addresses are assigned to each var in the powers of their size and each size is of power 2.In structures the var are assigned in sequential order.if padding is not done then float may not satisfy these values.To satisfy these conditions structure padding is done.



 Posted by: sindhusha kodali    

Contact sindhusha kodali  Contact sindhusha kodali


If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer
When is a switch statement better than multiple if statements?
View Answer
What is the difference between goto and longjmp() and setjmp()?
View Answer
What is an lvalue?
View Answer
Array is an lvalue or not?
View Answer
What is page thrashing?
View Answer
What is a const pointer?
View Answer
When should the register modifier be used? Does it really help?
View Answer
when should the volatile modifier be used?
View Answer
Can a variable be both const and volatile?
View Answer
How reliable are floating-point comparisons?
View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL C Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/5939/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

1.97