首页 百科知识 计算字节大小

计算字节大小

时间:2022-09-15 百科知识 版权反馈
【摘要】:使用 sizeof 操作符计算int, float, double 和 char四种变量字节大小。sizeof 是 C 语言的一种单目操作符,如C语言的其他操作符++、--等,它并不是函数。sizeof 操作符以字节形式给出了其操作数的存储大小。运行结果:Size of int: 4 bytesSize of float: 4 bytesSize of double: 8 bytesSize of char: 1 byte运行结果:Size of int = 4 bytesSize of long = 8 bytesSize of long long = 8 bytesSize of double = 8 bytesSize of long double = 16 bytes

使用 sizeof 操作符计算int, float, double 和 char四种变量字节大小。

sizeof 是 C 语言的一种单目操作符,如C语言的其他操作符++、--等,它并不是函数。

sizeof 操作符以字节形式给出了其操作数的存储大小。


运行结果:

Size of int: 4 bytes

Size of float: 4 bytes

Size of double: 8 bytes

Size of char: 1 byte


运行结果:

Size of int = 4 bytes 

Size of long = 8 bytes

Size of long long = 8 bytes

Size of double = 8 bytes

Size of long double = 16 bytes


免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。

我要反馈