something strange about sizeof struct ?
Posted: Tue Aug 15, 2006 8:56 am
I have a problem with sizeof struct
with this code
how can sizeof( struct A ) and sizeof( struct B ) is 8 ???
can anyone explain ?
and this
how can the code above give result 16 for both sizeof(struct A) and sizeof(struct B) ??
can someone please explain ?
with this code
Code: Select all
#include <stdio.h>
struct A
{
int a;
short b;
};
struct B
{
int a;
short b,c;
};
int main()
{
printf("%d %d\n",sizeof(struct A),sizeof(struct B));
return 0;
}
can anyone explain ?
and this
Code: Select all
#include <stdio.h>
struct A
{
long long a;
short b;
};
struct B
{
long long a;
short b,c;
};
int main()
{
printf("%d %d\n",sizeof(struct A),sizeof(struct B));
return 0;
}
can someone please explain ?