c++ 各种数据类型 所占字节数

void DataLength()
{
    qDebug() << "type: \t\t" << "************size**************" << endl;
       qDebug() << "bool: \t\t" << QString::fromLocal8Bit("所占字节数:") << sizeof(bool);
       qDebug() << "char: \t\t" << QString::fromLocal8Bit("所占字节数:") << sizeof(char);
       qDebug()  << "signed char: \t" << QString::fromLocal8Bit("所占字节数:") << sizeof(signed char);
       qDebug()  << "unsigned char: \t" << QString::fromLocal8Bit("所占字节数:") << sizeof(unsigned char);
       qDebug()  << "wchar_t: \t" << QString::fromLocal8Bit("所占字节数:" )<< sizeof(wchar_t);
       qDebug()  << "short: \t\t" << QString::fromLocal8Bit("所占字节数:") << sizeof(short);
       qDebug()  << "int: \t\t" << QString::fromLocal8Bit("所占字节数:") << sizeof(int);
       qDebug()  << "unsigned: \t" <

c++ 各种数据类型 所占字节数_第1张图片

    cout << "type: \t\t" << "************size**************" << endl;
    cout << "bool: \t\t" << "所占字节数:" << sizeof(bool);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t\t最小值:" << (numeric_limits::min)() << endl;
    cout << "char: \t\t" << "所占字节数:" << sizeof(char);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t\t最小值:" << (numeric_limits::min)() << endl;
    cout << "signed char: \t" << "所占字节数:" << sizeof(signed char);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t\t最小值:" << (numeric_limits::min)() << endl;
    cout << "unsigned char: \t" << "所占字节数:" << sizeof(unsigned char);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t\t最小值:" << (numeric_limits::min)() << endl;
    cout << "wchar_t: \t" << "所占字节数:" << sizeof(wchar_t);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t\t最小值:" << (numeric_limits::min)() << endl;
    cout << "short: \t\t" << "所占字节数:" << sizeof(short);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t\t最小值:" << (numeric_limits::min)() << endl;
    cout << "int: \t\t" << "所占字节数:" << sizeof(int);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t最小值:" << (numeric_limits::min)() << endl;
    cout << "unsigned: \t" << "所占字节数:" << sizeof(unsigned);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t最小值:" << (numeric_limits::min)() << endl;
    cout << "long: \t\t" << "所占字节数:" << sizeof(long);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t最小值:" << (numeric_limits::min)() << endl;
    cout << "unsigned long: \t" << "所占字节数:" << sizeof(unsigned long);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t最小值:" << (numeric_limits::min)() << endl;
    cout << "double: \t" << "所占字节数:" << sizeof(double);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t最小值:" << (numeric_limits::min)() << endl;
    cout << "long double: \t" << "所占字节数:" << sizeof(long double);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t最小值:" << (numeric_limits::min)() << endl;
    cout << "float: \t\t" << "所占字节数:" << sizeof(float);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t最小值:" << (numeric_limits::min)() << endl;
    cout << "size_t: \t" << "所占字节数:" << sizeof(size_t);
    cout << "\t最大值:" << (numeric_limits::max)();
    cout << "\t最小值:" << (numeric_limits::min)() << endl;
    cout << "string: \t" << "所占字节数:" << sizeof(string) << endl;
    // << "\t最大值:" << (numeric_limits::max)() << "\t最小值:" << (numeric_limits::min)() << endl;  
    cout << "type: \t\t" << "************size**************" << endl;
    system("pause");

你可能感兴趣的:(QT)