C 学习笔记 之 struct

struct 占用的内存大小:

struct{

char a;

short b;

int c;

char d;

}//占用12字节

 

struct{

char a;

char b;

short c;

int d;

}//占用 8 个字节

 

struct{

char a:1;

char b:1;

}//占用1个字节

 

struct{

char a:1;

int b:1;

}//占用4个字节

 

涉及到的概念:内存对齐(提升寻址效率)、

posted @ 2012-07-08 21:42  lipeil  阅读(177)  评论(0编辑  收藏  举报