- 1、本文档共6页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
实验十 指针与函数实验目的理解并掌握函数的指针等概念,学会使用指向函数的指针变量,学会编写返回指针值的函数。要点提示1.函数名代表函数的入口地址,函数的入口地址即为函数的指针。 2.指向函数的指针变量的定义格式: 数据类型标识符 (*指针变量名)();函数的调用可以通过函数名调用,也可以通过函数指针调用。4.返回指针值的函数定义格式:类型标识符 *函数名(形式参数表);5. 当函数有多个计算结果或返回值时,可以定义函数返回值的类型为指针类型。实验内容指向函数的指针变量的定义和引用返回指针值的函数的定义和引用指向函数的指针变量作为函数参数实验步骤读懂并输入程序,完成填空后输出结果。1. 写一个函数,将字符串中的小写字母转换成大写字母。在main函数中输入字符串,并输出结果。main(){ void convert(); /* 函数说明 */ char str[10]; printf(\nInput a string:); scanf(%s, str); 【 】 printf(\nOutput the string:%s, str);}void convert(char p[10]) /* 函数定义 */{ int i=0; while (*(p+i) !=\0) { if (*(p+i)=a *(p+i)=z) *(p+i)=*(p+i)-【 】; /* 将小写字母转换为大写字母 */ i++; }} 程序运行结果Input a string: NbaOutput the string: 【 】main(){ void convert(); /* 函数说明 */ char str[10]; printf(\nInput a string:); scanf(%s, str); convert(str); printf(\nOutput the string:%s, str);}void convert(char p[10]) /* 函数定义 */{ int i=0; while (*(p+i) !=\0) { if (*(p+i)=a *(p+i)=z) *(p+i)=*(p+i)-32; /* 将小写字母转换为大写字母 */ i++; }} Input a string:NbaOutput the string:NBAPress any key to continue实验2main(){ void convert(); /* 函数说明 */ char str[10]; 【 】; printf(\nInput a string:); scanf(%s, str); 【 】; (*p)(str); /* 函数调用 */ printf(\nOutput the string:%s, str);}void convert(char p[10]) /* 函数定义 */{ int i=0; while (*(p+i) !=\0) { if (*(p+i)=a *(p+i)=z) *(p+i)=*(p+i)-32; /* 将小写字母转换为大写字母 */ i++; }} 程序运行结果 Input a string: NbaOutput the string: 【 】main(){ void convert(); /* 函数说明 */ char str[10]; int (*p)(); printf(\nInput a string:); scanf(%s, str); p=convert; (*p)(str); /* 函数调用 */ printf(\nOutput the string:%s, str);}void convert(char p[10]) /* 函数定义 */{ int i=0; while (*(p+i) !=\0) { if (*(p+i)=a *(p+i)=z) *(p+i)=*(p+i)-32; /* 将小写字母转换为大写字母 */ i++; }} Input a string:NbaOutput the string:NBAPress any key to continue实验3{static int score [][4]={{60,70,80,90,},{56,89,67,88},{34,78,90,66}}; int * search(); /* 函数说明 */ int * p; int i,m; printf(\nenter t
文档评论(0)