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
相关推荐
樱木Plus2 天前
深拷贝(Deep Copy)和浅拷贝(Shallow Copy)
c++
blasit4 天前
笔记:Qt C++建立子线程做一个socket TCP常连接通信
c++·qt·tcp/ip
肆忆_5 天前
# 用 5 个问题学懂 C++ 虚函数(入门级)
c++
不想写代码的星星5 天前
虚函数表:C++ 多态背后的那个男人
c++
端平入洛7 天前
delete又未完全delete
c++
端平入洛8 天前
auto有时不auto
c++
郑州光合科技余经理8 天前
代码展示:PHP搭建海外版外卖系统源码解析
java·开发语言·前端·后端·系统架构·uni-app·php
feifeigo1238 天前
matlab画图工具
开发语言·matlab
dustcell.8 天前
haproxy七层代理
java·开发语言·前端
norlan_jame8 天前
C-PHY与D-PHY差异
c语言·开发语言