I come, I see, I conquer

                    —Gaius Julius Caesar

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  15 随笔 :: 339 文章 :: 128 评论 :: 146万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
复制代码
#include <stdio.h>
// Alignment requirements
// (typical 32 bit machine)
// char         1 byte
// short int    2 bytes
// int          4 bytes
// double       8 bytes

// structure A
typedef struct structa_tag
{
    
char        c;
    
short int   s;
} structa_t;

// structure B
typedef struct structb_tag
{
    
short int   s;
    
char        c;
    
int         i;
} structb_t;

// structure C
typedef struct structc_tag
{
    
char        c;
    
double      d;
    
int         s;
} structc_t;

// structure D
typedef struct structd_tag
{
    
double      d;
    
int         s;
    
char        c;
} structd_t;

int main()
{
    printf(
"sizeof(structa_t) = %d\n"sizeof(structa_t));
    printf(
"sizeof(structb_t) = %d\n"sizeof(structb_t));
    printf(
"sizeof(structc_t) = %d\n"sizeof(structc_t));
    printf(
"sizeof(structd_t) = %d\n"sizeof(structd_t));
    
    
return 0;
}
复制代码
posted on   jcsu  阅读(677)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示