码迷,mamicode.com
首页 > 其他好文 > 详细

sizeof(struct)

时间:2014-10-01 20:02:41      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   sp   div   

#include<stdio.h>
#include<iostream>
#include<assert.h>
using namespace std;

struct s1
{
    char a;  
    char b;  
    char c;  
};
bubuko.com,布布扣
struct s2 { int a; char b; short c; }; bubuko.com,布布扣 struct s3 { char a; int b; short c; };
bubuko.com,布布扣
int main() { cout<<sizeof(s1)<<endl; cout<<sizeof(s2)<<endl; cout<<sizeof(s3)<<endl; } void func() { cout<<sizeof(char)<<endl; cout<<sizeof(short)<<endl; cout<<sizeof(int)<<endl; cout<<sizeof(long)<<endl; cout<<sizeof(float)<<endl; cout<<sizeof(double)<<endl; cout<<sizeof(char *)<<endl; cout<<sizeof(int *)<<endl; }

 

sizeof(struct)

标签:style   blog   http   color   io   os   ar   sp   div   

原文地址:http://www.cnblogs.com/huangcongcong/p/4003430.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!