设为首页 加入收藏

TOP

指针 (更换地址保存的地址)
2017-10-13 10:28:12 】 浏览:8446
Tags:指针 更换 地址 保存
 1 /*
 2 指针 (更换地址保存的地址)
 3 2017-1-11 16:59:24 
 4 
 5 */
 6 
 7 
 8 # include <iostream>
 9 using namespace std;
10 int main()
11 {
12     int i=10,j=20;
13     int *p=&i;//"p"是一个地址;"*p"是一个值 
14     cout<<i<<endl;
15     cout<<&i<<endl;
16     cout<<j<<endl;
17     cout<<&j<<endl;
18     cout<<p<<endl;
19     cout<<*p<<endl;
20     p=&j;   //地址和值都会被代替 
21     cout<<"更换地址后"<<endl;
22     cout<<i<<endl;
23     cout<<&i<<endl;
24     cout<<j<<endl;
25     cout<<&j<<endl;
26     cout<<p<<endl;
27     cout<<*p<<endl;
28     return 0;
29     
30 }
View Code

 

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇用C++实现的元胞自动机 下一篇【算法专题】工欲善其事必先利其..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目