计算机常用单位换算:
1Byte=8bit
1kb=1024Byte
1Mb=1024kb
1Gb=1024Mb
1Tb=1024Gb
注:Byte是字节,bit是位,是0或者1c语言基本数据类型如下图所示



上述图所描述的类型字节大小以及取值范围都是在Vs2019环境下得到的,不同的开发环境可能结果不一样,有人可能会有疑问❓,为什么long类型和int类型字节数一样呢?不应该大于int吗?这是我们c语言的规定,只要long的字节数大于等于int的字节数就可以了!
3.上述的数据我们都可以在vs2019中得到,用关键字sizeof()实现,具体程序如下:

#include <stdio.h>
#include <string.h>
int main()
{
printf("%d\n", sizeof(int)); //4
printf("%d\n", sizeof(unsigned int)); //4
printf("%d\n", sizeof(short)); //2
printf("%d\n", sizeof(unsigned short)); //2
printf("%d\n", sizeof(long)); //4
printf("%d\n", sizeof(unsigned long)); //4
printf("%d\n", sizeof(long long)); //8
printf("%d\n", sizeof(unsigned long long)); //8
printf("%d\n", sizeof(char)); //1
printf("%d\n", sizeof(unsigned char)); //1
printf("%d\n", sizeof(float)); //4
printf("%d\n", sizeof(double)); //8
printf("%d\n", sizeof(long double)); //8
return 0;
}
版权声明:本文为m0_61365813原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。