C++中数据类型的大小

在 C++ 中,数据类型的大小在不同系统架构(32 位和 64 位)上可能会有所不同。以下是一些常见数据类型在这两种系统中通常占用的字节数。

基本数据类型大小

数据类型 32 位系统 64 位系统
char 1 byte 1 byte
short 2 bytes 2 bytes
int 4 bytes 4 bytes
long 4 bytes 8 bytes
long long 8 bytes 8 bytes
float 4 bytes 4 bytes
double 8 bytes 8 bytes
long double 8 bytes(可能) 16 bytes(或更大,取决于编译器和系统)

指针类型大小

指针的大小与系统架构相关,因此在 32 位和 64 位系统中会有所不同:

数据类型 32 位系统 64 位系统
int* 4 bytes 8 bytes
char* 4 bytes 8 bytes
float* 4 bytes 8 bytes
double* 4 bytes 8 bytes
void* 4 bytes 8 bytes
相关推荐
Brilliantwxx4 分钟前
【C++】 vector(代码实现+坑点讲解)
开发语言·c++·笔记·算法
野生技术架构师5 分钟前
2026年最全Java面试题及答案汇总(建议收藏,面试前看这篇就够了)
java·开发语言·面试
百锦再1 小时前
Auto.js变成基础知识学习
开发语言·javascript·学习·sqlite·kotlin·android studio·数据库开发
叼烟扛炮1 小时前
C++第三讲:类和对象(中)
开发语言·c++·类和对象
KuaCpp1 小时前
C++新特性学习
c++·学习
墨染千千秋2 小时前
C/C++ Keywords
c语言·c++
ximu_polaris2 小时前
设计模式(C++)-行为型模式-中介者模式
c++·设计模式·中介者模式
iDao技术魔方2 小时前
DeepSeek TUI:原生 Rust 打造的终端 AI 编码 Agent
开发语言·人工智能·rust
jghhh012 小时前
认知无线电中基于能量检测的双门限频谱感知的 MATLAB 仿真
开发语言·matlab
Mr数据杨2 小时前
【Codex】用教案主体模块沉淀标准化教学设计内容
java·开发语言·django·codex·项目开发