C/C++按地址輸出的方式

#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
 unsigned char *p1;
 unsigned long *p2;
 p1=(unsigned char *)0x801000;
 p2=(unsigned long *)0x810000;
 
 cout << "p1 = " << (void *)p1 << endl;
 cout << "p2 = " << (void *)p2 << endl;
 cout << "p1 + 5 = " <<(void *)(p1 + 5)<< endl;
 cout << "p2 + 5 = " << (void *)(p2 + 5) << endl;
 printf("p1 = %x\n",p1);
 printf("p2 = %x\n",p2);
 printf("p1 + 5 = %x\n",p1 +5);
 printf("p2 + 5 = %x\n",p2 +5);


 return 0;
}


 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章