o / p问题 [英] o/p problem
问题描述
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...
推荐答案
2005年12月23日星期五04:33:33 -0800,fidlee写道:
On Fri, 23 Dec 2005 04:33:33 -0800, fidlee wrote:
应该是什么?
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
fidlee写道:
什么应该是
printf的ouptut(" %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...
字符常量可以包含多个字符,整数价值
是实施定义的。您需要查阅编译器附带的
文档以获取详细信息,但是您可以观察到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
@Robert
所以你的意思是说这个声明将在
不同的编译器上表现不同??
i也试过了
printf("%d",''+ a' );并且它给出11105 on g ++(linux)和turboC
(windows)我不认为他们是编译器依赖...
有人可以告诉我为什么编译器在
下面的行为? (43 * 256 + 43 = 11051)
@ Robert
so u mean to say that this statement will behave differently on the
different compilers??
i also tried out
printf("%d",''+a''); and it gives 11105 on g++ (linux) and turboC
(windows) i dont think they are compiler dependednt...
Can someone please tell me as to why the compiler behaves in the
following way?? (43*256+43=11051)
这篇关于o / p问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!