设为首页 加入收藏

TOP

在32位与64位系统比较C++主要类型的长度
2018-01-09 06:06:33 】 浏览:351
Tags:32位与 64位 系统 比较 主要 类型 长度

在32位与64位系统比较C++主要类型的长度

1、源代码

#include 
  
   

using namespace std;

int main(int argc, const char * argv[])
{
    cout << "sizeof(char) =      " << sizeof(char) << endl;
    cout << "sizeof(short) =     " << sizeof(short) << endl;
    cout << "sizeof(int) =       " << sizeof(int) << endl;
    cout << "sizeof(float) =     " << sizeof(float) << endl;
    cout << "sizeof(long) =      " << sizeof(long) << endl;
    cout << "sizeof(void *) =    " << sizeof(void *) << endl;
    cout << "sizeof(long long) = " << sizeof(long long) << endl;
    cout << "sizeof(double) =    " << sizeof(double) << endl;

    return 0;
}
  

2、32位系统

macos系统(版本号:10.13.2)

编译器:clang++

Apple LLVM version 9.0.0 (clang-900.0.39.2)

Target: x86_64-apple-darwin17.3.0)

编译选项:-arch i386

sizeof(char) =      1
sizeof(short) =     2
sizeof(int) =       4
sizeof(float) =     4
sizeof(long) =      4
sizeof(void *) =    4
sizeof(long long) = 8
sizeof(double) =    8

3、64位系统

macos系统(版本号:10.13.2)

编译器:clang++

Apple LLVM version 9.0.0 (clang-900.0.39.2)

Target: x86_64-apple-darwin17.3.0)

编译选项:-arch x86_64

sizeof(char) =      1
sizeof(short) =     2
sizeof(int) =       4
sizeof(float) =     4
sizeof(long) =      8
sizeof(void *) =    8
sizeof(long long) = 8
sizeof(double) =    8

4、长度对比表

32位系统与64位系统主要类型长度对比表
类型 32位系统长度 64位系统长度 说明
char 1 1  
short 2 2  
int 4 4  
float 4 4  
long 4 8 long类型:32位系统4字节,64位系统8字节
void * 4 8 指针类型:32位系统4字节,64位系统8字节
long long 8 8  
double 8 8  


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C++二进制小数、对异域的理解 下一篇c++中头文件互相包含的方法讲解

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目