#include<iostream>#include<iomanip>
using namespace std;intmain(){//定义一个const变量constint a =10;//把a的地址赋值给pint*p =(int*)&a;//通过解引用修改p所保存的地址的值*p =12;//setw()为输出长度
cout<<"地址:"<< p <<setw(20)<<"a:"<<&a <<endl;
cout <<*p <<setw(10)<< a << endl;return0;}
#include<iostream>#include<iomanip>
using namespace std;intmain(){//加了volatile告知系统变量易变不要优化,则会只有一个地址volatileconstint a =10;int*p =(int*)&a;*p =12;//setw()为输出长度
cout<<"地址:"<< p <<setw(20)<<"a:"<<&a <<endl;
cout <<*p <<setw(10)<< a << endl;return0;}