int a = printf("%d \ n",a); [英] int a=printf("%d\n",a);

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

问题描述

表达式int a = printf("%d \ n",a);依赖于实现?

我认为它会产生结果2,但我得到4206596(结果

可能会因你的机器而异),我想知道产生的值是否是一个记忆

地址和这个表达式有什么特别之处?

does the expression int a=printf("%d\n",a); implementation dependent ?
I supposed it would produced the result 2, but i got 4206596 (result
may vary on your machine), i wonder if the value produced was a memory
address and anything special with this expression ?

推荐答案

sugaray写道:
sugaray wrote:
是吗expression int a = printf("%d \ n",a);实施依赖?


不,它是未定义的,因为当你将
传递给printf()时,'a''尚未初始化。不要这样做。

我想它会产生结果2
does the expression int a=printf("%d\n",a); implementation dependent ?
No, it''s undefined, since `a'' hasn''t been initialized at the time you
pass its value to printf(). Don''t do that.
I supposed it would produced the result 2




为什么?


Jeremy。



Why?

Jeremy.


Jeremy Yallop< je **** @ jdyallop.freeserve.co.uk>在消息新闻中写道:< bn ************ @ ID-114079.news.uni-berlin.de> ...
Jeremy Yallop <je****@jdyallop.freeserve.co.uk> wrote in message news:<bn************@ID-114079.news.uni-berlin.de>...
sugaray写道:
sugaray wrote:
表达式int a = printf("%d \ n",a);依赖于实现?
不,它是未定义的,因为在您将其值传递给printf()时,a尚未初始化。不要这样做。
does the expression int a=printf("%d\n",a); implementation dependent ?
No, it''s undefined, since `a'' hasn''t been initialized at the time you
pass its value to printf(). Don''t do that.




未定义是指未定义的值或者未定义的行为?



By undefined do you mean undefined "value" or undefined "behaviour"?

我认为它会产生结果2
I supposed it would produced the result 2



为什么?

杰里米。



Why?

Jeremy.




-

Imanpreet Singh Arora



--
Imanpreet Singh Arora


Minti写道:
Jeremy Yallop< je **** @ jdyallop.freeserve.co.uk>在消息新闻中写道:< bn ************ @ ID-114079.news.uni-berlin.de> ...
Jeremy Yallop <je****@jdyallop.freeserve.co.uk> wrote in message news:<bn************@ID-114079.news.uni-berlin.de>...
sugaray写道:
sugaray wrote:
>表达式int a = printf("%d \ n",a);依赖于实现?
> does the expression int a=printf("%d\n",a); implementation dependent ?



不,它是未定义的,因为在您将其值传递给printf()时,a尚未初始化。不要这样做。



No, it''s undefined, since `a'' hasn''t been initialized at the time you
pass its value to printf(). Don''t do that.



未定义是指未定义的值或未定义的行为?



By undefined do you mean undefined "value" or undefined "behaviour"?




在这种情况下没有区别。 'a''的值是

不确定,因此使用它时的行为是未定义的。


Jeremy。



In this case there is no difference. The value of `a'' is
indeterminate, so the behaviour when it is used is undefined.

Jeremy.


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

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