标签:com 结果 ret ace image 用法 detail https 区别
具体就不细说了,主要是分得清,不要弄混了,直接看下面的例子
#include<iostream>
using namespace std;
int main()
{
//定义数组
int arr1[3];
int arr2[3][10];
//数组指针
int *p1 = arr1;
int(*p2)[10] = arr2;
//首地址
cout << arr1 << " " << p1 << " " << &arr1[0] << " " << &p1[0] << endl;
//第二行的首地址
cout << arr1 + 1 << " " << p1 + 1 << " " << &arr1[1] << " " << &p1[1] << endl;
//首地址
cout << arr2 << " " << p2 << " " << p2[0] << " " << &p2[0][0] << endl;
//第二行的首地址
cout << arr2 + 1 << " " << p2 + 1 << " " << p2[1] << " " << &p2[1][0] << endl;
//arr2[1][1]的地址
cout << arr2[1] + 1 << " " << p2[1] + 1 << " " << &p2[1][1] << " " << &(*(*(p2 + 1) + 1)) << endl;
//指针数组,下面三种写法效果一样
int *(n1[10]); //指针大小32位机为4,64位机为8
int *(n2)[10];
int *n3[10];
cout << sizeof(n1) << " " << n1 << " " << n1 + 1 << " " << &n1[2] << endl;
cout << sizeof(n2) << " " << n2 << " " << n2 + 1 << " " << &n2[2] << endl;
cout << sizeof(n3) << " " << n3 << " " << n3 + 1 << " " << &n3[2] << endl;
system("pause");
return 0;
}
运行结果:
区别和相关用法如上,可对比查看。
1.指针数组与数组指针详解
2.让你不再害怕指针——C指针详解(经典,非常详细)
标签:com 结果 ret ace image 用法 detail https 区别
原文地址:https://www.cnblogs.com/clwsec/p/11518009.html