- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Structures,Unions,BitManipulations,andEnumerations优秀讲义
Chapter 8 - Structures, Unions, Bit Manipulations, and Enumerations 8.1 Introduction Structures Collections of related variables (aggregates) under one name Can contain variables of different data types Commonly used to define records to be stored in files Combined with pointers, can create linked lists, stacks, queues, and trees 8.2 Structure Definitions Example struct card { char *face; char *suit; }; struct introduces the definition for structure card struct card is the structure name and is used to declare variables of the structure type struct card contains two members of type char * These members are face and suit 8.2 Structure Definitions struct information A struct cannot contain an instance of itself Can contain a member that is a pointer to the same structure type A structure definition does not reserve space in memory Instead creates a new data type used to declare structure variables Declarations Declared like other variables: struct card oneCard, deck[ 52 ], *cPtr; Can use a comma separated list: struct card { char *face; char *suit; } oneCard, deck[ 52 ], *cPtr; 8.2 Structure Definitions Valid Operations Assigning a structure to a structure of the same type Taking the address () of a structure Accessing the members of a structure Using the sizeof operator to determine the size of a structure 结构体的声明 结构体的声明:得到一种新的数据类型 struct 结构类型名{ 成员列表; }; 例:定义一个复数结构 struct complex{ float re ; float im; }; 定义结构类型变量 struct complex x,y; 结构体变量的引用 直接使结构类型变量 struct complex x; x.re = 10.2 ; x.im = 20.5 ; 通过指向结构类型对象的指针来访问 结构体变量的初始化 struct complex x = {10.2, 20.5}; struct STUDENT { long int serial_number; // 学号 char name[10]; // 姓名 int sex; // 性别 int age; // 年龄 char department[30]; // 所属系 }; struct STUDENT a= ”Zhang” , 1, 18, ”Computer” }; 8.3 Initializing Structures Initializer lists Example: struct card oneCard = { Three, Hearts }; Assignment statements Example:
您可能关注的文档
最近下载
- 基于“教、考、评”一致性的高中语文阅读教学策略.pptx VIP
- 最新土工击实、液塑限、颗粒分析自动计算表.xls VIP
- 学前教育评价第二版教学课件完整版.pptx
- MB670-1掘锚机结构原理及操作方法.pptx VIP
- 中国人民大学-BK138A网络、群体与市场.doc VIP
- 岩土工程勘察规范(GB 50021-2009).pdf VIP
- 2025年统编版语文四年级上册语文单元备课.pdf VIP
- 西方人类学发展史的再认识与中国人类学的未来.doc VIP
- 导航控制系统(NCS)系列:Saab Avionics ELSIN-300_(9).软件更新与版本管理.docx VIP
- 产后保健服务技术规范.pdf VIP
文档评论(0)