问题描述
你好,
我想打印一个签名的八进制。
有了签名的短片,它的打印速度为%hi但是八角形怎么样?
Tk!
Hello,
I would like to print a signed octal.
With a signed short it''s printf %hi but what about an octal ?
Tk !
推荐答案
%ho
%ho
%ho
%ho
%它是% off%to%work%we%go go ...
-
Richard Heathfield< http://www.cpax.org.uk>
电子邮件:-http:// www。 + rjh @
谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>
Usenet是一个奇怪的放置" - dmr 1999年7月29日
%it''s %off %to %work %we %go...
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
%ho
%ho
这是无格式短片的格式说明符,格式为
八进制,不适用于格式化为八进制的signed int。
* printf()函数不提供OP想要的内容。如果你想要一个以八进制打印的
signed int,你可以这样做:
printf("%c%o",octal< 0?' ' - '':'''',八进制< 0?-octal:octal);
...虽然这可能会因octal而失败< -INT_MAX。
Phil
That''s the format specifier for an unsigned short to be formatted as an
octal, not for a signed int formatted as an octal.
The *printf() functions don''t provide what the OP wants. If you want a
signed int printed as an octal you can do this:
printf("%c%o",octal<0 ? ''-'' : '' '', octal<0 ? -octal : octal);
...although this may fail for octal < -INT_MAX.
Phil
这篇关于打印一个signel八进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!