您的位置:首页 > 其它

二十二 位结构体的存储方式

2014-01-03 21:13 120 查看
include <stdio.h>

typedef struct RTP

{

unsigned int cc : 4; // 存放在低4位

unsigned int x : 1;

unsigned int p : 1;

unsigned int ver : 2;

unsigned int pt : 7;

unsigned int m : 1;

unsigned int seq : 16; // 存放在高16位

} RTP_HEAD; // 切记: 只是在存的时候才分大小端

RTP_HEAD test;

int main()

{

test.cc = 4; // 0100

test.x = 1; // 1

test.p = 0; // 0

test.ver= 2; // 10

test.pt = 9; // 0001001

test.m = 0;

test.seq = 5; // 0000000000000101



printf("%d \n",test); // 00000000000001010000100110010100

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: