7.3 指针所占内存空间
提问:指针也是种数据类型,那么这种数据类型占用多少内存空间?
#include <iostream>
using namespace std;
int main()
{
int a = 10;
int* p;
p = &a;//指针指向数据a的地址
cout << *p << endl;//解引用
cout << sizeof(int *) << endl;
cout << sizeof(float *) << endl;
cout << sizeof(double *) << endl;
cout << sizeof(char *) << endl;
system("pause");
return 0;
}
最后更新于
这有帮助吗?