awidy
#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。

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-07-03
  • 2022-12-23
  • 2021-05-26
  • 2021-11-18
  • 2021-10-06
  • 2022-12-23
猜你喜欢
  • 2021-04-23
  • 2021-05-24
  • 2021-07-25
  • 2022-01-28
  • 2021-07-10
  • 2021-12-30
  • 2022-12-23
相关资源
相似解决方案