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

posted @ 2020-05-13 19:01  Aniston  阅读(500)  评论(0)    收藏  举报