L
Lokicer
Hi, i am a c newbie, i write some code to get size of structs
i compile and run it in VC6.0
//#pragma pack(1)
typedef struct tag_NullMsg
{
int a[0];
} tNullMsg;
typedef struct tag_CharMsg
{
char c;
int a[0];
} tCharMsg;
//#pragma pack()
int main(int arg)
{
printf("size of tNullMsg is %d\n", sizeof(tNullMsg));
printf("size of tCharMsg is %d\n", sizeof(tCharMsg));
}
when i open #pragma pack(1) switch the size of tNullMsg is 1 and tCharMsg is
1
when i close #pragma pack(1) switch the size of tNullMsg is 1 and tCharMsg
is 4
who can explain it ?
thanks very much!
Lokicer
i compile and run it in VC6.0
//#pragma pack(1)
typedef struct tag_NullMsg
{
int a[0];
} tNullMsg;
typedef struct tag_CharMsg
{
char c;
int a[0];
} tCharMsg;
//#pragma pack()
int main(int arg)
{
printf("size of tNullMsg is %d\n", sizeof(tNullMsg));
printf("size of tCharMsg is %d\n", sizeof(tCharMsg));
}
when i open #pragma pack(1) switch the size of tNullMsg is 1 and tCharMsg is
1
when i close #pragma pack(1) switch the size of tNullMsg is 1 and tCharMsg
is 4
who can explain it ?
thanks very much!
Lokicer