指针地址方面问题搞不明白请大侠看看
#include <iostream>using namespace std;struct S{ int i; int *p;};int main(int argc, char *argv[]){ S s; int *p=&s.i; p[0]=1; // s.i p[1]=8; // &s.i 的下一个位置 也就是s.p的开始位置 cout<< p[0] << " " << s.i <<endl; cout<< &p[0] << " " << &s.i <<endl; cout<< p[1] << " " << s.p << " " <<endl;//s.p的地址为什么是0x8 ?? cout<< &p[1] << " " << &s.p << " " << &s.p[1] <<endl; cout<<endl; s.p=p; cout<< p[0] << " " << s.i <<endl; cout<< &p[0] << " " << &s.i <<endl; cout<< p[1] << " " << s.p << s.p[1] <<endl; cout<< &p[1] << " " << &s.p << &s.p[1] <<endl; s.p[1]=2;//*(s.p+1)=2 *(&s.p[0]+1)=2 cout<< s.p <<" "<< p << " " << &s.p << endl; //s.p的地址为什么是0x2?? return 0;}