64位/32位
struct data{
char t1;
char t2;
unsigned short t3;
unsigned long t4;
}; 16 /8
struct data{
char t1;
int t2;
short t3;
}; 12 /12
struct s1 {
char c1;
int i;
char c2;
};12 /12
struct s2 {
char c1;
char c2;
int i;
};8 /8
typedef struct Test
{
short a;
struct {
int b;
double c;
char d;
}p;
int e;
}Test; 40/24
typedef struct Test
{
short a;
struct {
int b;
double c[10];
char d;
};
int e;
}Test;112 /96
struct C{
char b;
int a;
short c;
}; 12 /12
struct C {
char a;
char b[3];
char c;
}; 5 /5
typedef struct
{
int b;
char a;
long e;
char c;
float d;
double t;
}node; 32 /28
验证大小端
int main(int argc, const char *argv[])
{
int a=0x12345678;
char*p=(char*)&a;
if(*p==0x78){
printf("小端存储\n");
}else printf("大端存储\n");
return 0;
}