天下

记录修行的印记

字节对齐

#include <iostream>
#include 
<list>
#include 
<map>
#include 
<afxwin.h>
using namespace std;
typedef 
struct _A1
{  
    
char b;  
    
double a;  
    
char c;  
}A1; 

typedef 
struct _A2
{  
    
char b;  
    
double a;  
    
char c; 
    
int  d;
}A2; 

typedef 
struct _A3
{  
    
char b;  
    
char c;  
    
double a;  
}A3; 

typedef 
struct _A4
{  
    
char b;  
    
double a;  
    
char c; 
    
char d;
    
char e;
    
int  f;
}A4; 

typedef 
struct _A5{
    
char a[3];
    
int b;
    
char c;
    
char d;
}A5;

typedef 
struct _A6{
    
char a[5];
    
int b;
    
char c;
    
char d;
}A6;


int main ()
{   
    
    cout 
<< sizeof(A1)<< endl;
    cout 
<< sizeof(A2)<< endl;
    cout 
<< sizeof(A3)<< endl;
    cout 
<< sizeof(A4)<< endl;
    cout 
<< sizeof(A5)<< endl;
    cout 
<< sizeof(A6)<< endl;
    
return 0;
}

posted on 2010-11-23 09:54 天下 阅读(140) 评论(0)  编辑 收藏 引用 所属分类: C/C++


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2010年11月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

导航

统计

常用链接

留言簿(4)

随笔分类(378)

随笔档案(329)

链接

最新随笔

搜索

最新评论