hello!guys,recent days ,i come across a problem when i write a C program,that is "How to calculate the size of struct ",i have a part of C source code below:
 #include <stdio.h>
 struct b 
    float f;    
    int a[2];
    char p;

  int main(void)
    printf("sizeof(struct(b))=%d\n",sizeof(struct b));
    return 0;
After compiling using GCC 4.6.1,the result is
then ...
I think the
= (sizeof(float)) + 2*(sizeof(int)) + (sizeof(char))
=13 not equal 16.

oh my god !!
Could some one tell me why?thank you very much! ^@^
(compile environment Windows XP sp3,TDM-GCC 4.6.1,X86 architecture)

Last edited by wdliming; 15Mar2012 at 17:30..