#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;
p[1]=5;
cout<<p[0]<<" "<<s.i<<endl;
cout<<&p[0]<<" "<<&s.i<<endl;
cout<<p[1]<<" "<<s.p<<" "<<endl;
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]=1;
cout<<s.p<<" "<<&s.p<<endl;
}
程序员面试宝典_7.2 _面试例题9
最新推荐文章于 2018-12-07 09:24:04 发布