按位定义结构体
来源:互联网 发布:mac 的火箭按钮不见了 编辑:程序博客网 时间:2024/06/05 19:38
按位定义一个结构体
struct s_DosAttributes
{
unsigned ReadOnly :1;
unsigned Hidden :1;
unsigned System :1;
unsigned VolumeID :1;
unsigned Directory :1;
unsigned Archive :1;
unsigned reserved :2;
};
这个结构共占用4个字节, ReadOnly占用Bit0, Hidden占用Bit1...reserve占用Bit7和Bit6
比如
struct s_DosAttributes st;
memset(&st, 0, sizeof(st));
st.ReadOnly = 1;
st.VolumeID = 1;
st.reserved = 3;
unsigned char c;
memcpy(&c, &st, sizeof(c));
这时c 的值是0xc9;
阅读全文
0 0
- 按位定义结构体
- 按位定义结构体
- 结构体中的位定义
- 位域结构体的定义示例及其与联合体的定义使用
- 结构体,联合的位域定义方法,以及结构体大小的计算
- 结构体的定义和使用和位段的使用
- 结构体定义
- OPENFILENAME 结构体定义
- 结构体定义
- Nasm 结构体定义
- 如何定义结构体
- typedef 结构体定义
- 结构体的定义
- 定义两个结构体
- typedef 定义结构体
- 结构体定义 方法
- 结构体定义
- 结构体的定义
- 学习笔记-自定义密码输入框和自定义数字密码软键盘
- 决策树学习笔记(一)
- Spring 的四种方式依赖注入
- iOS 高德地图怎么在屏幕内显示所有的Marker?
- Python中的闭包
- 按位定义结构体
- JDK8的ParallelStream遍历无序的问题
- 倒计时时钟 面向对象
- html标签
- 计算两点间的距离
- Collection集合之操作元素方法实现
- 为什么不要把ZooKeeper用于服务发现?
- 基于链表的栈实现
- [JavaEE