sizeof(struct)

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

struct s1
{
    char a;  
    char b;  
    char c;  
};
struct s2 { int a; char b; short c; }; struct s3 { char a; int b; short c; };
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; }
原文地址:https://www.cnblogs.com/huangcongcong/p/4003430.html