C/C++ 各数据类型占用字节数 您所在的位置:网站首页 float类型数据占字节数为 C/C++ 各数据类型占用字节数

C/C++ 各数据类型占用字节数

2023-03-25 04:48| 来源: 网络整理| 查看: 265

第一次写文章,有点小激动,主要的目的是将正在学习的知识记录一下,方便随时复习,也给跟我一样正在学习C++的同学分享一下我的学习过程,博客中所用的知识都是我在网上或者书上查到的(其实我已经学过一段时间了,现在想复习记录一下,哈哈哈),出处当时没有记录,如有侵权,请联系删除,如有错误,欢迎大家指正,谢谢,费话不多说,开始吧

C/C++ 在16bit & 32bit & 64bit编译器下各数据类型字节数

C/C++ 中不同目标平台下各数据类型长度是不同的,数据类型的实际长度由编译器在编译期间通过编译参数指定目标平台而确定的。 short int,int,long int 的字节数都是随编译器指定的目标平台而异,但是在ANSI/ISO指定:

sizeof(short int) = 32 bit (4 Byte).16bit 编译器:char == 1 Byte;short int == 2 Byte;int == 2 Byte;unsigned int == 2 Byte;long == 4 Byte;unsigned long == 4 Byte;long long == 8 Byte;float == 4 Byte;double == 8 Byte.32bit 编译器:​char == 1 Byte;short int == 2 Byte;int == 4 Byte;unsigned int == 4 Byte;long == 4 Byte;unsigned long == 4 Byte;long long == 8 Byte;float == 4 Byte;double == 8 Byte.64bit 编译器:char == 1 Byte;short int == 2 Byte;int == 4 Byte;unsigned int == 4 Byte;long == 4 Byte;unsigned long == 4 Byte;long long == 8 Byte;float == 4 Byte;double == 8 Byte.指针变量所占字节

指针变量所占字节数是根据编译器的寻址空间决定宽度的:

16 bit编译器寻址空间为16 bit,所以指针变量宽度为2 Byte;32 bit编译器寻址空间为32 bit,所以指针变量宽度为4 Byte;64 bit编译器寻址空间为64 bit,所以指针变量宽度为8 Byte. 以上32bit & 64bit编译器均是在vs2017上测试所得



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有