下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、本节主题:返回指针的函数返回指针的函数#include int max(int x, int y)int t; if(x y)t = x;elset = y; return t;int main()inta, b, c;scanf(%d %d, &a, &b); c = max(a, b);printf(max = %d n, c);return 0;#include int *max(int *x, int *y)int *t; if(*x *y)t = x;elset = y; return t;int main()inta, b, *p; scanf(%d %d, &a, &b); p
2、= max(&a, &b);printf(max = %d n, *p);return 0;类型标识符 *函数名(形式参数表列)回顾“野指针”#include int main( )int a,b;int *p1,*p2; a=100;b=10;p1=&a; p2=&b;printf(%d %dn, a, b); printf(%d %dn, *p1, *p2); return 0;#include int main()int a, b;int *p1, *p2;*p1=10;*p2=100;printf(%d %dn, a, b);printf(%d %dn, *p1, *p2);retur
3、n 0;不能对未赋值的指针变量作“指向”运算#include int main()int a, b;int *p1, *p2; p1=0 x100000; p2=0 x100004;printf(%d %dn, a, b); printf(%d %dn, *p1, *p2); return 0;不能用整数为一个指针变量赋值返回值不可以是已经失效的地址#include int *max(int *x, int *y)int t;if(*x *y)t = *x;elset = *y; return &t;int main()inta, b, *p; scanf(%d %d, &a, &b); p = max(&a, &b);printf(max = %d n, *p); return 0;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 骨干水网调度信息化建设技术导则-地方标准编制说明
- 中医护理学 教案 模块三 中医理论下人体的构成内容知识点
- 云南省文山州2024-2025学年高三上学期阶段检测卷(二)英语试题
- 土地规划合理性问题分析
- 助理薪酬考核专员岗位说明书
- 旅行社出国游学市场开发探讨
- 上半我国疫苗批签发2.77亿支其中国产疫苗占比超90
- 数字化设计与制造第版教学配套课件苏春主编
- 2022-2023学年广东省广州市天河区六年级(上)期末英语试卷(含答案)
- 细菌 课件-2024-2025学年(2024)人教版生物七年级上册
- 马克思主义学院教师教学工作规范
- 《草原上的小木屋课件》
- 人教版九年级数学上册 第22章 二次函数 知识点总结及练习
- 细胞培养技术培训课件
- 水冲法及引孔钢板桩施工重难点及控制措施
- 2022年河南省安全员B证(项目负责人)考试近年真题汇总(含答案)
- XX市智慧矿山建设解决方案V1.0
- 人教版小学四年级音乐上册(五线谱)全套课件
- 【大单元教学方案】相互作用-力单元概览
- (新版)水利工程高级工程师考试参考题库大全-中(多选题部分)
- 非洲鼓乐课件
评论
0/150
提交评论