printf("%d",INT_MAX); [英] printf("%d", INT_MAX);

查看:104
本文介绍了printf("%d",INT_MAX);的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,


其他地方提到过printf(%d,INT_MAX);

是实现定义的。为什么?是因为INT_MAX

值是实现定义的,所以输出在实现时取决于
,还是更微妙的东西

输出的以下也是实现定义的:


if(INT_MAX == 65535)

printf("%d",INT_MAX);

else

printf("%d",65535);


谢谢,

Yevgen

Hey,

It was mentioned elsewhere that printf("%d", INT_MAX);
is implementation-defined. Why? Is it because INT_MAX
value is implementation-defined so output depends
on implementation, or is it something more subtle so
that output of the following is also implementation-defined:

if (INT_MAX == 65535)
printf("%d", INT_MAX);
else
printf("%d", 65535);

Thanks,
Yevgen

推荐答案

Yevgen Muntyan写道:
Yevgen Muntyan wrote:

嘿,


其他地方提到printf(%d,INT_MAX);

是实现定义的。为什么?是因为INT_MAX

值是实现定义的,所以输出在实现时取决于
,还是更微妙的东西

输出的以下也是实现定义的:


if(INT_MAX == 65535)

printf("%d",INT_MAX);

else

printf("%d",65535);
Hey,

It was mentioned elsewhere that printf("%d", INT_MAX);
is implementation-defined. Why? Is it because INT_MAX
value is implementation-defined so output depends
on implementation, or is it something more subtle so
that output of the following is also implementation-defined:

if (INT_MAX == 65535)
printf("%d", INT_MAX);
else
printf("%d", 65535);



嗯,我再次使它过于复杂。是这个实现定义的:


printf("%d \ nn",65535);


(如果\ n很重要,然后我们在第一段代码之后打印\ n,

它在main()中。


Yevgen


Yevgen Muntyan写道:
Yevgen Muntyan wrote:

Yevgen Muntyan写道:
Yevgen Muntyan wrote:

>嘿,

其他地方提到printf(%d,INT_MAX);
是实现定义的。为什么?是因为INT_MAX
值是实现定义的,所以输出依赖于实现,或者它是否更为微妙,以至于以下输出也是实现定义的:

if(INT_MAX == 65535)
printf("%d",INT_MAX);

printf("%d",65535);
>Hey,

It was mentioned elsewhere that printf("%d", INT_MAX);
is implementation-defined. Why? Is it because INT_MAX
value is implementation-defined so output depends
on implementation, or is it something more subtle so
that output of the following is also implementation-defined:

if (INT_MAX == 65535)
printf("%d", INT_MAX);
else
printf("%d", 65535);



嗯,我再次让它过于复杂。是这个实现定义的:


printf("%d \ n",65535);


Um, I again made it overcomplicated. Is this implementation-defined:

printf("%d\n", 65535);



咨询标准后,上面应该是


printf("%d \ nn",32767) ;


好​​吧。


Yevgen

After consulting the standard, the above should be

printf("%d\n", 32767);

Oh well.

Yevgen


Yevgen Muntyan写于03 14/07 13:29,:
Yevgen Muntyan wrote On 03/14/07 13:29,:

Yevgen Muntyan写道:
Yevgen Muntyan wrote:

>> Yevgen Muntyan写道:
>>Yevgen Muntyan wrote:

>>>嘿,

其他地方提到过printf("%d",INT_MAX);
是实现定义的。为什么?是因为INT_MAX
值是实现定义的,所以输出依赖于实现,或者它是否更为微妙,以至于以下输出也是实现定义的:

if(INT_MAX == 65535)
printf("%d",INT_MAX);

printf("%d",65535);
>>>Hey,

It was mentioned elsewhere that printf("%d", INT_MAX);
is implementation-defined. Why? Is it because INT_MAX
value is implementation-defined so output depends
on implementation, or is it something more subtle so
that output of the following is also implementation-defined:

if (INT_MAX == 65535)
printf("%d", INT_MAX);
else
printf("%d", 65535);


嗯,我再次让它变得过于复杂。这是实现定义的:

printf("%d \ n",65535);


Um, I again made it overcomplicated. Is this implementation-defined:

printf("%d\n", 65535);




咨询标准后,上面应该是


printf("%d \ n" ;,32767);



After consulting the standard, the above should be

printf("%d\n", 32767);



这里似乎有几个问题。


INT_MAX的值是实现定义的,所以
printf生成的
输出(%d \ n,INT_MAX)是实现 -

定义的。什么都没有错误操作,但

a严格遵守程序不得执行它。


printf的影响("%d \ nn,65535)是实施 -

未定义(如果我可以写一个术语)。如果实现 -

定义的INT_MAX值>> 65535,那么输出定义为

。如果INT_MAX< 65535,常量65535是unsigned int类型的
,行为未定义,因为

"%d"需要一个签名的int。因此,实现 -

定义行为是否定义良好或未定义。


printf的影响(%d \ n, 32767)在所有

托管实现中都是相同的(除了I / O错误)。


-
呃********* @ sun.com


这篇关于printf(&quot;%d&quot;,INT_MAX);的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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