- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Linux+ Guide to Linux Certification, Second Edition A First Book of ANSI C, Fourth Edition A First Book of ANSI CFourth Edition Chapter 7 Modularity Using Functions: Part II Objectives Variable Scope Variable Storage Class Pass by Reference Case Study: Swapping Values Recursion Common Programming and Compiler Errors Variable Scope If variables created inside a function are available only to the function itself, they are said to be local to the function, or local variables Scope is the section of the program where the variable is valid or “known” Variable Scope (continued) Variable Scope (continued) A variable with a local scope has had storage set aside for it by a declaration statement made within a function body A variable with global scope is one whose storage has been created for it by a declaration statement located outside any function Variable Scope (continued) Variable Scope (continued) Program 7.1 produces the following output From main(): firstnum = 10 From main(): secnum = 20 From valfun(): firstnum = 10 From valfun(): secnum = 30 From main() again: firstnum = 40 From main() again: secnum = 20 While a function is executing, only the storage area for the variables and parameters created by this function are automatically accessed Variable Scope (continued) If a variable that is not local to the function is used by the function, the program searches the global storage areas for the correct name The scope of a variable does not influence the data type of the variable Variable Scope (continued) When to Use Global Declarations The scoping rules for symbolic constants and function prototypes are the same as for variables When a symbolic constant has a general meaning that is applicable throughout an application, it makes good programming sense to declare it globally at the top of a source code file Coding a function prototype as a global makes sense when the function is used by a number of other functions in a source code file Doing so avoids repeating the pro
您可能关注的文档
最近下载
- 新能源汽车专业实训室建设方案(供货价200万)2021108.doc VIP
- 王浩—水资源全过程动态评价理论方法与实践.ppt VIP
- 部编版小学语文四年级下册第6课《飞向蓝天的恐龙》精品课件.pptx
- 水池满水试验规定(闭水试验).pdf VIP
- 专题1.6 角平分线的判定与性质【十大题型】(举一反三)(北师大版)(原卷版).docx VIP
- 潍柴WD615系列柴油机使用与维修中册.pdf VIP
- 高中全套思维导图.doc VIP
- 医防融合的课件.pptx VIP
- 预检分门诊消毒隔离制度.docx VIP
- Unit 3 Same or Different ? Section A 2a~2e 课件+内嵌音频.pptx VIP
文档评论(0)