c++中 指针占几个字节
程序员文章站
2024-03-14 08:59:58
...
转载:
https://blog.csdn.net/qq_31442743/article/details/81628058
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a = 1;
int *p1 = &a;
cout << "int " << sizeof(p1) << endl;
float b = 1.23;
float *p2 = &b;
cout << "float " << sizeof(p2) << endl;
double c = 1.3456;
double *p3 = &c;
cout << "double" << sizeof(p3) << endl;
system("pause");
return 0;
}
在WIN32编译器下
在x64编译器下
由此得出结论:
指针在Win32下的大小为4字节
x64下的大小为8字节