c - Output of following code with integer, float, char variable -
this question has answer here:
when run following, gives me output 20. int of 4 byte,float of 4 byte , character array of 10 byte, total 18 byte. why getting output 20 byte?
#include<stdio.h> struct emp { int id; char name[10]; float f; }e1; main() { printf("\n\tsize of structure is==>%d\n",sizeof(e1)); }
see :
int 4
char 10 ==> 12 alignment
float 4
like :
iiii cccc cccc cc^^ <-- data pading make address alignment. ffff
total 20
Comments
Post a Comment