bitwise opertion
来源:互联网 发布:淘宝保证金交30的条件 编辑:程序博客网 时间:2024/06/05 12:49
#include<stdio.h>#include<stdlib.h>#include<stdint.h>typedef struct{ uint8_t a:6; uint8_t b:4; uint8_t day:5; uint8_t hour:5;}my_t;int main(){my_t *p = (my_t *)malloc(sizeof(my_t)); if(!p) { return -1;}p->a = 17;p->b = 13;p->day = 31;p->hour = 23;uint8_t *buf = calloc(3, sizeof(uint8_t));if(!buf){free(p);return -2;} printf("Hello size=%d, %d, %d, %d, %d\n", sizeof(my_t), p->a, p->b, p->day, p->hour); buf[0] = (p->b<<6)|(p->a & 0x3f); buf[1] = (p->hour<<7)|(p->day<<2)|(p->b>>2); buf[2] = (p->hour>>1)&0x0f; printf("buf[0]=0x%02x, buf[1]=0x%02x, buf[2]=0x%02x\n", buf[0], buf[1], buf[2]);if(p)free(p);if(buf)free(buf); return 0;}
0 0
- bitwise opertion
- bitwise
- bitwise copy
- bitwise const
- Bitwise Operation
- Apache 开启服务提示The requested opertion has failed!
- LeetCode[Bitwise]----Bitwise AND of Numbers Range
- Bitwise Operation Explained
- Bitwise Operation Explained
- Bitwise add/Multipy
- TJU Bitwise Reverse
- Bitwise Operation及用处
- [总结] Bitwise operations
- Bitwise copy semantics
- python Bitwise shift
- Bitwise operation and usage
- What are bitwise operators?
- Python bitwise operator
- 博客第一天!
- ahk 3.内置函数
- ahk 4.本机代码交互GUI,MsgBox,InputBox
- 前端问题(10)
- ahk 5.文件目录和磁盘管理
- bitwise opertion
- Gson(一)
- 配置main_cfg.h main.c文件
- Ansible自动化离线搭建安装
- Web开发方向读书记录与观后感
- linux下搭建SVN服务器完全手册
- PyCharm 2016.3 注册码
- poj1019——Number Sequence(数学)
- 非静态内部类、非静态匿名内部类会持有外部对象的引用