C/C++之数据类型的大小

不同数据类型的大小

数据类型

大小

char

1

int

4

short

2

long

4

bool

1

float

4

double

8

typename*

4

typename[n]

n

char* = “123…n”

string = “123…n”

n+1

struct

根据结构体最大的数据类型大小为单元

以结构体定义变量的顺序为准

进行内存分配和对齐

原文地址:https://www.cnblogs.com/fr-ruiyang/p/9599383.html