问题描述
printf("%d",''++'')应该是什么;
ascii值为+是43 ...在turboC中输出为11051 ...(我感到惊讶的是它在编译时没有出错...)某人
解释我为如何输出...
what should be the ouptut of
printf("%d",''++'');
the ascii value of + is 43... the output comes as 11051 in turboC... (i
was surprised it doesnt throw an error on compiling... ) someone
explain me as to how this output comes...
推荐答案
6.4.4.4字符常数 #10:
包含多个
字符的整数字符常量的值(例如,''ab''),或包含
不映射到单字节执行字符,
实现定义。
在你的情况下,43 * 256 + 43.
-
Pieter Droogendijk< pieter at binky dot org dot uk>
PGP / 1E92DBBC [Make皇帝最好的方式。 ] binky.org.uk
6.4.4.4 "Character constants" #10:
The value of an integer character constant containing more than one
character (e.g., ''ab''), or containing a character or escape sequence that
does not map to a single-byte execution character, is
implementation-defined.
In your case, 43 * 256 + 43.
--
Pieter Droogendijk <pieter at binky dot org dot uk>
PGP/1E92DBBC [ Make way for the Emperor''s Finest. ] binky.org.uk
字符常量可以包含多个字符,整数价值
是实施定义的。您需要查阅编译器附带的
文档以获取详细信息,但是您可以观察到43 * 256 + 43 = 11051这一事实。
Robert Gamble
Character constants can contain multiple characters, the integer value
of which is implementation-defined. You will need to consult the
documentation that came with your compiler for the details but you
might observe the fact that 43*256+43=11051.
Robert Gamble
这篇关于o / p问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!