C语言程序设计基础实验报告8.docx
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《C语言程序设计基础实验报告8.docx》由会员分享,可在线阅读,更多相关《C语言程序设计基础实验报告8.docx(8页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、C语言程序设计基础实验报告8 实验8 指针 一、实验目的 1、通过实验进一步掌握指针的概念,会定义和使用指针变量; 2、能正确使用数组的指针和指向数组的指针变量; 3、能正确使用字符串的指针和指向字符串的指针变量; 二、实验内容和步骤 1、改错 (1)指出下面程序错误的原因. main( ) int x=10,y=5,*px,*py; px=py; px=&x; py=&y; printf(*px=%d,*py=%d,*px,*py); #include void main() int x=10,y=5,*px,*py; px=&x; py=&y; printf(px=%d,py=%d,*px
2、,*py); (2)下面的程序试图有如下运行结果: which style you want to : Capital ( c ) or uncapital ( a ):c COMPUTER Which sytle you want to : Capital ( c ) or uncapital ( a ) : u computer 请调试下面的程序,使其有如上执行结果. #include main () char s*;char c; printf(which style you want to :ln); printf(capital ( c ) or uncapital(a):); c=
3、getchar(); if(c=c)strcpy(s,COMPUTER); else strcpy(s,computer); put(s); #include #include #include void main() char *s;char c; printf(which style you want to :n); printf(capital(c) or uncapital(a):); c=getchar(); s=calloc(20, sizeof(char); /分配存储空间if(c=c) strcpy(s,COMPUTER); else strcpy(s,computer); p
4、uts(s); (3)下面的程序能获得上述运行结果吗 main() char *S=COMPUTER; char c; printf(which style you want to n); printf(capital (c) or uncapital(u);); c=getchar(); if(c=c) put(s); else s=computer; puts(s); #include void main() char *s=COMPUTER; char c; printf(which style you want to:n); printf(capital(c) or uncapital
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言程序设计 基础 实验 报告
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内