gpt4 book ai didi

c - 为什么这两个结构的大小不同?

转载 作者:行者123 更新时间:2023-12-02 07:11:57 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Why isn't sizeof for a struct equal to the sum of sizeof of each member?

#include<stdio.h>

struct csie {
char c;
short s;
int i;
double e;
};

struct ceis {
char c;
double e;
int i;
short s;
};

int main(void) {
printf("csie = %d\n", sizeof(struct csie));
printf("ceis = %d\n", sizeof(struct ceis));
return 0;
}

输出是:

csie = 16

ceis = 24

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com