【ThinkingInC++】8、说明,浅谈数据类型的大小

本文通过C++代码展示了各种基本数据类型所占用的字节数,包括整型、浮点型及其无符号版本,有助于理解不同数据类型的存储需求。
/**
* 特征:说明。浅谈数据类型的大小
* 时刻:2014年8一个月10日本11:02:02
* 笔者:cutter_point
*/

#include<iostream>

using namespace std;

int main()
{
    char c;
    unsigned char cu;
    short int is;
    short iis;
    unsigned short int isu;
    unsigned short iisu;
    int i;
    unsigned int iu;
    long int il;
    long iil;
    unsigned long int ilu;
    unsigned long iilu;
    float f;
    double d;
    long double ld;

    cout
        <<"\n char= "<<sizeof(c)
        <<"\n unsigned= "<<sizeof(cu)
        <<"\n short int= "<<sizeof(is)
        <<"\n short= "<<sizeof(iis)
        <<"\n unsigned short int= "<<sizeof(isu)
        <<"\n unsigned short= "<<sizeof(iisu)
        <<"\n int= "<<sizeof(i)
        <<"\n unsigned int= "<<sizeof(iu)
        <<"\n long int= "<<sizeof(il)
        <<"\n long= "<<sizeof(iil)
        <<"\n unsigned long int= "<<sizeof(ilu)
        <<"\n unsigned long= "<<sizeof(iilu)
        <<"\n float= "<<sizeof(f)
        <<"\n double= "<<sizeof(d)
        <<"\n long double= "<<sizeof(ld)
        <<endl;

    return 0;
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值