标签:style blog http color io os ar sp div
#include<iostream> using namespace std; int main() { char a[2]={7,3}; char *p0=NULL,*p1=NULL; p0=&a[0]; p1=&a[1]; cout<<p0<<endl; cout<<p1<<endl; cout<<p0-p1<<endl; cout<<"************"<<endl; cout<<(int*)p0<<endl; cout<<(int*)p1<<endl; cout<<(int*)p0-(int*)p1<<endl; system("pause"); return 0; }
结果:
分析:
p,p1是char型的指针,指向的是数组元素的地址,所以相差1。
标签:style blog http color io os ar sp div
原文地址:http://www.cnblogs.com/awidy/p/3997475.html