Why is struct padding needed?



Why is struct padding needed?..

Answer / Mayank Sharma

Struct padding in C is necessary to ensure alignment of structures during memory allocation. This alignment ensures that data can be accessed quickly and efficiently, as some processors require that certain types of variables start at a specific memory address. For example, some systems might require an integer to start on a 4-byte boundary or a float to start on a 4-byte boundary as well.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }

3 Answers   ME, pspl,


extern static int i func() { i =10; i++; printf("%d \n",i); } main() { i =20; printf("%d \n",i); func(); printf("%d \n",i); }

2 Answers  


Where static variables are stored in c?

1 Answers  


What is the use of header files?

1 Answers  


I heard that you have to include stdio.h before calling printf. Why?

1 Answers  


what is a c-language.what is do.

4 Answers   HCL,


difference between function & structure

9 Answers   Verizon,


hi , please send me NIC written test papers to sbabavalli@gmail.com

0 Answers   NIC,


What is oops c?

1 Answers  


How we can set and clear bit in a byte using macro function?

2 Answers   L&T, Samsung,


What is the output from this program? #include <stdio.h> void do_something(int *thisp, int that) { int the_other; the_other = 5; that = 2 + the_other; *thisp = the_other * that; } int main(void) { int first, second; first = 1; second = 2; do_something(&second, first); printf("%4d%4d\n", first, second); return 0; }

3 Answers  


why return type of main is not necessary in linux

1 Answers   TCS,


Categories