- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
7.6 位域(位段) 很多信息的存储只需一个bit或几个bits,如是/否,或者是几个状态的编码。 在特殊的条件下,为节省存储空间,可将若干个需不同bit的变量压缩到一块存储空间中。使用同一数据类型的不同分量进行访问。 一种殊的结构体,结构体分量是位构成的 位域(位段) struct tagName { unsigned 分量名 :位宽度(常量表达式); ... }; 无位域名时表示指定宽度位不用 位宽度为0时表示下一位域从下一字节开始 7.7 位运算/位操作 ~ | ^ 移位运算可替代2的幂运算 符号保持不变 7.7 共用体 union 不同类型的变量占用“同一”存储空间。 union tagUnionName { }; 构体和位域是将不同数据类型或者位宽的变量捆绑聚集组织在一起但占用的空间是紧靠一起连续的区域; 共用体是不同分量占用自同一首地址开始的区域,开始重叠。 思考题 +5分 对多数组与结构体数组实现同一功能进行比较。 淮海工学院计算机工程学院 杨世通 2010-2011-2学期 C语言程序设计 东港选课 7.1 枚举 7.2 结构体类型声明 7.3 结构体变量定义与引用 7.4 结构体数组 7.5 结构体指针变量 7.6 结构体的应用: 链表 二叉树 7.7 位域 7.8 共用体 小结 练习、作业及实验 7.1 枚举 无符号的一组常量。 月份: 星期: 颜色: // for definition of enumerated type enum [tag] {enum-list} [declarator];??? // for declaration of variable of type tag enum tag declarator;??? 枚举 enum enum [tag] {enum-list} [declarator];???// for definition of enumerated type enum tag declarator;???// for declaration of variable of type tag The enum keyword specifies an enumerated type. An enumerated type is a user-defined type consisting of a set of named constants called enumerators. By default, the first enumerator has a value of 0, and each successive enumerator is one larger than the value of the previous one, unless you explicitly specify a value for a particular enumerator. Enumerators needn’t have unique values. The name of each enumerator is treated as a constant and must be unique within the scope where the enum is defined. An enumerator can be promoted to an integer value. However, converting an integer to an enumerator requires an explicit cast, and the results are not defined. In C, you can use the enum keyword and the tag to declare variables of the enumerated type. In C++, you can use the tag alone. In C++, enumerators defined within a class are accessible only to member functions of that class unless qualified with the class name (for example, class_name::enumerator). You can use the same syntax for explicit access to the type name (class_name::tag). 请编程进行C语言的课程成绩处理,要求按输入的平时成绩和期末成绩算出总
文档评论(0)