指针 数组
#include<iostream>
using namespace std;
int main()
{int a[8]={0,1,2,3,4,5,6,7};
int *p=a;
cout<<a<<endl;//输出0012FF60
cout<<p<<endl;//输出0012FF60
cout<<*(p+1)<<endl;//输出1;
cout<<p[2]<<endl;//输出2;
return 0;
}
数组与字符数组和指针的关系略有不同;
using namespace std;
int main()
{int a[8]={0,1,2,3,4,5,6,7};
int *p=a;
cout<<a<<endl;//输出0012FF60
cout<<p<<endl;//输出0012FF60
cout<<*(p+1)<<endl;//输出1;
cout<<p[2]<<endl;//输出2;
return 0;
}
数组与字符数组和指针的关系略有不同;