32位机与64位机指针占用空间不同

Posted yuanshijie

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了32位机与64位机指针占用空间不同相关的知识,希望对你有一定的参考价值。

 

#include<iostream>
using namespace std;
int main()
{
cout << "sizeof(int*)="<<sizeof(int*) << endl;
cout << "sizeof(int)=" << sizeof(int) << endl;
}

c

32位机  sizeof(int*)=4,  sizeof(int)=4

64位机  sizeof(int*)=8,  sizeof(int)=4

 

  sizeof(int)指的int占用的字节数,字节数为4.

  sizeof(int*) 指的是指针变量占用的字节数

  32为机上:sizeof(char*)=sizeof(int*)=sizeof(short*)=sizeof(long*)=4
  64位机:sizeof(char*)=sizeof(int*)=sizeof(shor*)=sizeof(long*)=8

以上是关于32位机与64位机指针占用空间不同的主要内容,如果未能解决你的问题,请参考以下文章