在printf()中转换为二进制 [英] conversion to binary in printf()

查看:129
本文介绍了在printf()中转换为二进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在printf格式字符串中意外键入%b而不是%d

并获得了该数字的二进制表示。是标准C

还是编译器扩展?

解决方案

David Marsh写道:


我在printf格式字符串中意外键入了%b而不是%d

并获得了该数字的二进制表示。是标准C

还是编译器扩展?



%b不是标准转换说明符。

Robert Gamble


David Marshaécrit:


我在printf格式字符串中意外键入%b而不是%d并获得了

a二进制表示的数字。是标准C还是编译器

扩展名?



它在lcc-win32编译系统中用于二进制表示


也许其他printfs也这样做。 />


David Marsh< dm **** @ mail.comwrites:


我不小心输了%b而不是printf格式字符串中的%d和

得到了数字的二进制表示。是标准C还是

编译器扩展?



这是一个扩展名。它不太可能是*编译器*扩展,

但是; printf是运行时库的一部分。这是一个重要的

区别;例如,gcc使用系统上可用的任何运行时库。


-

Keith Thompson(The_Other_Keith) ks***@mib.org < http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *< http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。


I accidentally typed %b instead of %d in a printf format string
and got a binary representation of the number. Is that standard C
or a compiler extension?

解决方案

David Marsh wrote:

I accidentally typed %b instead of %d in a printf format string
and got a binary representation of the number. Is that standard C
or a compiler extension?

%b is not a Standard conversion specifier.

Robert Gamble


David Marsh a écrit :

I accidentally typed %b instead of %d in a printf format string and got
a binary representation of the number. Is that standard C or a compiler
extension?

It is used in the lcc-win32 compiler system for binary representation

Maybe other printfs do that too.


David Marsh <dm****@mail.comwrites:

I accidentally typed %b instead of %d in a printf format string and
got a binary representation of the number. Is that standard C or a
compiler extension?

It''s an extension. It''s not likely to be a *compiler* extension,
though; printf is part of the runtime library. This is an important
distinction; gcc, for example, uses whatever runtime library is
available on the system.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


这篇关于在printf()中转换为二进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆