#includeusing namespace std; int main() { //1、定义指针 int a = 10; //指针定义的语法:数据类型 * 指针变量名 int * p; //让指针记录变量a的地址 p = &a; cout<<"a的地址:"<<&a< 1,2,3,4,5,6,7,8,9,10}; int * p = arr; //arr就是数组的首地址 cout<<"利用访问第一个元素:"<<*p< cout<<*p2++< a的地址:0x7ffe3d066ad4 指针p维:0x7ffe3d066ad4 a=1000 *p=1000 sandbox> exited with status 0 /run.sh: line 12: 13 Segmentation fault (core dumped) ./a.out sandbox> exited with status 0利用访问第一个元素:1 利用指针访问第二个元素:2 1 2 3 4 5 6 7 8 9 10 sandbox> exited with status 0



