关于内存对齐的探索

来源:互联网 发布:决策与判断知乎 编辑:程序博客网 时间:2024/05/16 17:34
/*
  探索内存对齐
  coder:瞿鹏志 
 */
 #include <stdlib.h>
 #include <iostream>
 using namespace std;
 #pragma pack (8)
typedef struct node2{
 int a;//4
 char b;//4
 }node_type;
 struct node{
 char a;//4
 int b;//4
 double c;//8
 node_type s1;
 };
 int main(void)
 {
 cout<<sizeof(node)<<endl;
 return 0;
 }
/*
 内存对齐需要判断有效地址的首地址存储区域
*/
0 0