在64位操作系统上,如下数据结构占用的存储空间大小为多少字节
struct A{ unsigned int a; char b[2]; double c; short d; }
字节大小 | 32位系统 | 64位系统 |
---|---|---|
char | 1 | 1 |
short | 2 | 2 |
int | 4 | 4 |
指针 | 4 | 8 |
long | 4 | 8 |
float | 4 | 4 |
double | 8 | 8 |
long long | 8 | 8 |
注意指针和long都会从4字节变成8字节
int | int | int | int | char | char | 不 | 够 |
double | double | double | double | double | double | double | double |
short | short | 剩 | 余 | 自 | 动 | 补 | 齐 |
类型 | 16位平台 | 32位平台 | 64位平台 |
---|---|---|---|
char | 1 | 1 | 1 |
short | 2 | 2 | 2 |
short int | 2 | 2 | 2 |
int | 2 | 4 | 4 |
unsigned int | 2 | 4 | 4 |
float | 4 | 4 | 4 |
long | 4 | 4 | 8 |
long long | 8 | 8 | 8 |
unsigned long | 4 | 4 | 8 |
double | 8 | 8 | 8 |
指针 | 2 | 4 | 8 |
char* | 2 | 4 |
8
|