红联Linux门户
Linux帮助

struct 结构体的内容

发布时间:2010-01-29 11:44:24来源:红联作者:genesy
今天我查看了一下struct tm 结构体的内容,如下(十六进制按字节表示):
Current time is: 11:37:03
03 00 00 00 25 00 00 00 0b 00 00 00 1d 00 00 00
00 00 00 00 6e 00 00 00 05 00 00 00 1c 00 00 00
00 00 00 00 80 70 00 00 48 f0 76 09
struct tm 的定义如下:
struct tm{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
}
按道理应该有9*4=36个字节,但是为什么显示出来有44个字节,多出来的8字节是什么意思呢?各位高人指点一下。
文章评论

共有 2 条评论

  1. nunnunnun 于 2010-11-08 15:28:42发表:

    这个涉及到数据对齐的问题,你看看关于数据对齐的知识,就明白了。结构体的大小和编译器有关,不同数据对齐处理的编译器可能不同。

  2. genesy 于 2010-01-31 22:05:10发表:

    有人能帮我看一下吗?