当前位置:网站首页>学习位段(1)
学习位段(1)
2022-06-11 21:36:00 【爱学代码的学生】
1. 什么是位段?
位段的声明和结构是类似的,有两个不同:
1.位段的成员必须是 int、unsigned int或signed int 。
2.位段的成员名后边有一个冒号和一个阿拉伯数字。
例如:
struct A
{ int a: 2;
int b: 5;
int c: 10;
int d: 30;
};
A 就是一个位段类型。
那A的大小又是多少呢?
如果没有冒号后面的数字我们可以结构体的计算方式得到16,那这个大小是呢?

我们可以发现是只有八个字节,那我们可以知道这个数字的单位都是bit。
边栏推荐
- Leetcode - 第2天
- RPA丨首席财务官如何找到数字化转型“超级入口”?
- Add anti debugging function to game or code (application level)
- 如何将SAP API Hub 上提供的工作流导入到 SAP BTP 上
- Codeforces Round #740 Div. 2 解题报告
- Builder pattern
- Common file functions
- Codeforces Round #742 (Div. 2) F. One-Four Overload
- Analysis on the development history and market development status of China's system integration industry in 2020 [figure]
- Answer fans' questions | count the number and frequency of letters in the text
猜你喜欢
随机推荐
LabVIEW controls Arduino to realize ultrasonic ranging (advanced chapter-5)
Hangzhou Electric Zhongchao 91006 guess the weight
Redis basic data type (set)
作为一名 ABAP 资深顾问,下一步可以选择哪一门 SAP 技术作为主攻方向?
快速排序的优化
八、BOM - 章节课后练习题及答案
Master of a famous school has been working hard for 5 years. AI has no paper. How can the tutor free range?
How to manually send events exposed by SAP commerce cloud mock application using SAP kyma console
每日一题 -- 验证回文串
The upcoming launch of the industry's first retail digital innovation white paper unlocks the secret of full link digital success
如何使用事物码 SAT 查找某个 SAPGUI 屏幕字段对应的后台存储数据库表的名称试读版
AC automata
Common file functions
LeetCode-76-最小覆盖子串
8、 BOM - chapter after class exercises and answers
LaTex实战笔记 3-宏包与控制命令
Flutter series: detailed explanation of container layout commonly used in flutter
2021 Niuke multi school 5 double strings
JS performs non empty judgment on various data types of the returned data.
[v2.1] automatic update system based on motion step API (repair bug, increase completion display, support disconnection reconnection and data compensation)









![BZOJ3189 : [Coci2011] Slika](/img/46/c3aa54b7b3e7dfba75a7413dfd5b68.png)