++恶魔

编程入门 行业动态 更新时间:2024-10-25 07:22:58
本文介绍了++恶魔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我的怀疑是如此原始,我要求大家原谅我 事先...... 这里是代码片段: int main() { int x = 5; x = x ++ + ++ x; printf("%d",x); 返回0; } 我知道printf会打印一些x的值,没有人可以 准确预测所有时间对于所有编译器....但是,为什么我要求 这是因为这类问题不断出现在很多 问题论文中.... 帮我建议解决这个问题的方法.. 提前致谢!

Hello all, My doubt is going to be so primitive that i ask you all to forgive me beforehand.... Here''s the code snippet: int main() { int x=5; x=x++ + ++x; printf("%d",x); return 0; } I know that the printf is going to print some value of x which none can predict accurately for all times for all compilers....However,why i ask this is because such type of questions keep appearing in a lot of Question Papers.... Help me suggest a way to tackle this.. Thanks in advance!

推荐答案

以及我知道你应该像这样阅读这个等式 x = 5 = x ++ + ++ x = 5 + 6 = 11 i在某些Windows平台c和c ++中试用它并发现没有变化。 希望它有用 as well as i know you should read this equation like this x=5 =x++ + ++x = 5 + 6 =11 i have try it in some windows platform c and c++ and found no change. hope it will be useful

muttaa写道: 大家好, 我的怀疑是如此原始,我要求大家事先原谅我 .... 这里是代码片段: int main () {x / 5; x = x ++ + ++ x; printf("%d",x); 返回0; } 我知道printf会打印一些x值,没有人可以为所有编译器准确预测....但是,为什么我要问这是因为这类问题不断出现在很多问题论文中.... Hello all, My doubt is going to be so primitive that i ask you all to forgive me beforehand.... Here''s the code snippet: int main() { int x=5; x=x++ + ++x; printf("%d",x); return 0; } I know that the printf is going to print some value of x which none can predict accurately for all times for all compilers....However,why i ask this is because such type of questions keep appearing in a lot of Question Papers....

行为未定义,x可以现在是任何价值。我建议你 在< c-faq/expr/index.html>上阅读我们的常见问题解答,从问题开始 3.2。 Robert Gamble

The behavior is undefined, x can now be any value. I would suggest you read our FAQ at <c-faq/expr/index.html>, start with question 3.2. Robert Gamble

在发布后续内容时请引用相关背景,如果你已经 在发布之前潜伏一点(你应该已经完成​​了b )然后你会知道这一点。由于您使用的是Google网上论坛, 请阅读< cfaj.freeshell/google/>再次发布之前。 ash写道: Please quote relevant context when posting followups, if you had been lurking for a little which before you posted (which you should have done) then you would know this. Since you are using Google Groups, please read <cfaj.freeshell/google/> before posting again. ash wrote: 以及我知道你应该读这样的等式 x = 5 = x ++ + ++ x = 5 + 6 = 11 我在一些Windows平台c和c ++中尝试过,发现没有变化。希望它将是有用的 as well as i know you should read this equation like this x=5 =x++ + ++x = 5 + 6 =11 i have try it in some windows platform c and c++ and found no change. hope it will be useful

错了。仅仅因为它在你的编译器上有一种方式并不意味着蹲下,这种语言并不是由你的编译器定义的。正如我在 响应中所说,结果是未定义的,x可以是包含11的任何内容。 在序列点之间多次修改对象的值 未定义。我建议你遵循我给出的关于常见问题的OP 的相同建议。 Robert Gamble

Wrong. Just because it works one way on your compiler doesn''t mean squat, the language isn''t defined by your compiler. As I said in my response, the result is undefined, x can be anything including 11. Modifying the value of an object more than once between sequence points is undefined. I suggest you follow the same advice I gave the OP regarding the FAQ. Robert Gamble

更多推荐

++恶魔

本文发布于:2023-11-27 02:58:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636283.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:恶魔

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!