博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用C/C++的union联合体将十进制转二进制
阅读量:6086 次
发布时间:2019-06-20

本文共 1270 字,大约阅读时间需要 4 分钟。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
union
aa{
    
int
x;
    
struct
{
        
unsigned
char
b0:1;
        
unsigned
char
b1:1;
        
unsigned
char
b2:1;
        
unsigned
char
b3:1;
        
unsigned
char
b4:1;
        
unsigned
char
b5:1;
        
unsigned
char
b6:1;
        
unsigned
char
b7:1;
        
unsigned
char
b8:1;
        
unsigned
char
b9:1;
        
unsigned
char
b10:1;
        
unsigned
char
b11:1;
        
unsigned
char
b12:1;
        
unsigned
char
b13:1;
        
unsigned
char
b14:1;
        
unsigned
char
b15:1;
        
unsigned
char
b16:1;
        
unsigned
char
b17:1;
        
unsigned
char
b18:1;
        
unsigned
char
b19:1;
        
unsigned
char
b20:1;
        
unsigned
char
b21:1;
        
unsigned
char
b22:1;
        
unsigned
char
b23:1;
        
unsigned
char
b24:1;
        
unsigned
char
b25:1;
        
unsigned
char
b26:1;
        
unsigned
char
b27:1;
        
unsigned
char
b28:1;
        
unsigned
char
b29:1;
        
unsigned
char
b30:1;
        
unsigned
char
b31:1;
    
};
};

 

int
_tmain(
int
argc, _TCHAR* argv[])
{
    
aa a;
    
a.x = 456;
    
printf
(
"%d\n\n%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d "
,a.x,
        
a.b31,a.b30,a.b29,a.b28,a.b27,a.b26,a.b25,a.b24,a.b23,a.b22,a.b21,a.b20,a.b19,a.b18,a.b17,a.b16,a.b15,a.b14,a.b13,a.b12,a.b11,a.b10,a.b9,a.b8,a.b7,a.b6,a.b5,a.b4,a.b3,a.b2,a.b1,a.b0);
 
    
getchar
();
    
return
0;
}

转载于:https://www.cnblogs.com/china-jeffery/p/3503185.html

你可能感兴趣的文章
项目实践中Linux集群的总结和思考
查看>>
一行代码判断 IE 浏览器版本
查看>>
fopen和open函数的区别
查看>>
运维之我的docker-docker的网络管理
查看>>
xshell使用key登录linux
查看>>
vs2012 key
查看>>
java 时出现 could not open jvm.cfg 的解决办法之一
查看>>
md5加密与解密
查看>>
使用tar做备份
查看>>
从表到里学习JVM实现
查看>>
随机码的生成,python 2.7/eclipse 3.7+PyDev 2.4.0
查看>>
linux 下进程的最大线程数
查看>>
PHP类库转WORD, EXCEL, PDF, HTML格式
查看>>
UILabel
查看>>
H3C交换机DHCP服务配置命令+详解
查看>>
linux安全管理
查看>>
关于sqlserver2008本地计算机上的MSSQLSERVER服务不能启动的问题解决
查看>>
我们到底在为谁工作
查看>>
淘宝海量存储之单机事务面临的问题及解决办法
查看>>
使用struts2的token机制和cookie来防止表单重复提交
查看>>