C++中各种基本数据类型大小一览

  109**以下用`int`,**1018以下用long long

  C++代码如下

#include<iostream>
#include<string>
#include <limits>
using namespace std;

int main()
{
    cout << "type: ttt" << "************size**************" << endl;
    cout << "bool: ttt" << "numOfBytes:" << sizeof(bool);
    cout << "ttmaxValue:" << (numeric_limits<bool>::max)();
    cout << "ttttminValue:" << (numeric_limits<bool>::min)() << endl;

    cout << "char: ttt" << "numOfBytes:" << sizeof(char);
    cout << "ttmaxValue:" << (numeric_limits<char>::max)();
    cout << "ttttminValue:" << (numeric_limits<char>::min)() << endl;

    cout << "signed char: tt" << "numOfBytes:" << sizeof(signed char);
    cout << "ttmaxValue:" << (numeric_limits<signed char>::max)();
    cout << "ttttminValue:" << (numeric_limits<signed char>::min)() << endl;

    cout << "unsigned char: tt" << "numOfBytes:" << sizeof(unsigned char);
    cout << "ttmaxValue:" << (numeric_limits<unsigned char>::max)();
    cout << "ttttminValue:" << (numeric_limits<unsigned char>::min)() << endl;

    cout << "wchar_t: tt" << "numOfBytes:" << sizeof(wchar_t);
    cout << "ttmaxValue:" << (numeric_limits<wchar_t>::max)();
    cout << "ttttminValue:" << (numeric_limits<wchar_t>::min)() << endl;

    cout << "short: ttt" << "numOfBytes:" << sizeof(short);
    cout << "ttmaxValue:" << (numeric_limits<short>::max)();
    cout << "ttttminValue:" << (numeric_limits<short>::min)() << endl;

    cout << "int: ttt" << "numOfBytes:" << sizeof(int);
    cout << "ttmaxValue:" << (numeric_limits<int>::max)();
    cout << "tttminValue:" << (numeric_limits<int>::min)() << endl;

    cout << "unsigned: tt" << "numOfBytes:" << sizeof(unsigned);
    cout << "ttmaxValue:" << (numeric_limits<unsigned>::max)();
    cout << "tttminValue:" << (numeric_limits<unsigned>::min)() << endl;

    cout << "long: ttt" << "numOfBytes:" << sizeof(long);
    cout << "ttmaxValue:" << (numeric_limits<long>::max)();
    cout << "tttminValue:" << (numeric_limits<long>::min)() << endl;

    cout << "long long: tt" << "numOfBytes:" << sizeof(long long);
    cout << "ttmaxValue:" << (numeric_limits<long long>::max)();
    cout << "ttminValue:" << (numeric_limits<long long>::min)() << endl;

    cout << "unsigned long: tt" << "numOfBytes:" << sizeof(unsigned long);
    cout << "ttmaxValue:" << (numeric_limits<unsigned long>::max)();
    cout << "tttminValue:" << (numeric_limits<unsigned long>::min)() << endl;

    cout << "double: tt" << "numOfBytes:" << sizeof(double);
    cout << "ttmaxValue:" << (numeric_limits<double>::max)();
    cout << "tttminValue:" << (numeric_limits<double>::min)() << endl;

    cout << "long double: tt" << "numOfBytes:" << sizeof(long double);
    cout << "ttmaxValue:" << (numeric_limits<long double>::max)();
    cout << "tttminValue:" << (numeric_limits<long double>::min)() << endl;

    cout << "float: ttt" << "numOfBytes:" << sizeof(float);
    cout << "ttmaxValue:" << (numeric_limits<float>::max)();
    cout << "tttminValue:" << (numeric_limits<float>::min)() << endl;

    cout << "size_t: tt" << "numOfBytes:" << sizeof(size_t);
    cout << "ttmaxValue:" << (numeric_limits<size_t>::max)();
    cout << "ttminValue:" << (numeric_limits<size_t>::min)() << endl;

    cout << "ttt" << "************size**************" << endl;
    return 0;
}

C++中各种基本数据类型大小一览

原文链接: https://www.cnblogs.com/flyingrun/p/13485201.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    C++中各种基本数据类型大小一览

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/201373

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月12日 下午8:46
下一篇 2023年2月12日 下午8:46

相关推荐