#include<iostream>
using namespace std;
int main()
{
int a = 5;
int *p;
p = &a; // p保存a的地址
cout << a << endl;
cout << *p << endl; // *p 就是a的值 5
cout << &a << endl; // a的地址
cout << p << endl; // p里面存的就是a的地址,和&a一样
*p = 20; // 修改*p,a跟着变
cout << a; // 输出20
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: