- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Introduction to Computer (C Programming) Chapter 8 Structures and Unions Roadmap 8.1 Introduction 8.2 Defining a structure 8.3 Declaring structure variables 8.4 Structure initialization 8.5 Operations on structure 8.6 More complex constructions 8.7 Structure and functions 8.8 Unions 8.9 User-defined type declaration Problem 8.1 Introduction Arrays can be used to represent a group of data items that belong to the same type how can we represent a collection of data items of different types using a single name? 8.1 Introduction cont. C supports a constructed data type known as structures, a mechanism for packing data of different types. A structure is a convenient tool for handling a group of logically related data items. Structures help to organize complex data in a more meaningful way. The concept of a structure is analogous to that of a ‘record’ in many other languages. 8.2 Defining a structure Unlike arrays, structures must be defined first for their format that may be used later to declare structure variables. 8.2 Defining a structure cont. In defining a structure you may note the following syntax: 1. The template is terminated with a semicolon. 2. While the entire definition is considered as a statement, each member is declared independently for its name and type in a separate inside the template. 3. The tag name such as date can be used to declare structure variables of its type, later in the program. 8.3 Declaring structure variables A structure variable declaration is similar to the declaration of variables of any other data types. It includes the following elements: 1. The keyword struct. 2. The structure tag name. 3. List of variable names separated by commas. 4. A terminating semicolon. Example: struct student std1, std2, std3; 8.3 Declaring structure variables cont. The complete declaration is: 8.4 Structure Initialization Like any other data type, a structure variable can be initialized at compile time. C language does not permit the
您可能关注的文档
最近下载
- 金属工艺学 全套课件.ppt VIP
- 外研版(三起)(2024)三年级下册英语Unit 4《What’s your hobby?》第1课时教案 .pdf VIP
- Unit 4 What's your hobby 第三课时教案 2024-2025学年度 外研版英语三年级下册.docx VIP
- 老年患者麻醉管理专家共识.pptx
- 景区运营管理合作协议.doc VIP
- HGT21629-2021管架标准图图集标准.docx VIP
- 保健食品要掌握的全部基本知识【58页】.pptx VIP
- MDCG 2020-7 上市后临床随访 (PMCF) 计划模板中文版.docx VIP
- 基坑土方回填施工策划方案.doc VIP
- 半导体材料课件课件.pptx VIP
文档评论(0)