意外的结果

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

嗨 看看这段代码 包含< stdio.h> int main(void) { int i,j = 2; i = j ++ * ++ j * j ++; printf(" ;%d%d,i,j); 返回0; } acc。对我来说i&的价值观j分别为27,5和这是正确的,因为我在turbo c ++编译器上运行了这个,但如果我在lcc-win32编译器上运行它 我得到32& 5对于i&分别为。 为什么会这样呢

hi look at this code include <stdio.h> int main(void) { int i,j=2; i=j++ * ++j * j++; printf("%d %d",i,j); return 0; } acc. to me the values of i & j are 27,5 respectively & rightly so as i ran this on turbo c++ compiler but if i ran this on lcc-win32 compiler i got 32 & 5 for i & j respectively. why this is so

推荐答案

hi anshu 所有编译器依赖者 in lcc-win32编译器 首先代码从右到左运行 表示i = 4 * 4 * 2 它为我提供32 但在turboc编译器中它从左到右执行代码并取大价值 其中就是3 所以它给它27. 再见 Ankur ashu写道: hi anshu it all compiler depenedent in lcc-win32 compiler first the code run on right to left means i=4*4*2 it give 32 for i but in turboc compiler it execute code left to right and take big value among it i.e. 3 so thats y its give 27. bye Ankur ashu wrote: 嗨看看这段代码 包含< stdio.h> int main(无效) { int i,j = 2 ; i = j ++ * ++ j * j ++; printf("%d%d",i,j); 返回0; } acc。对我来说i&的价值观j分别为27,5和这是正确的,因为我在turbo c ++编译器上运行了这个,但如果我在lcc-win32编译器上运行它 我得到32& 5对于i&分别为。为什么会这样? hi look at this code include <stdio.h> int main(void) { int i,j=2; i=j++ * ++j * j++; printf("%d %d",i,j); return 0; } acc. to me the values of i & j are 27,5 respectively & rightly so as i ran this on turbo c++ compiler but if i ran this on lcc-win32 compiler i got 32 & 5 for i & j respectively. why this is so

ashu写道: ashu wrote: hi 看看这段代码 包含< stdio.h> int main(void) { int i,j = 2; i = j ++ * ++ j * j ++; hi look at this code include <stdio.h> int main(void) { int i,j=2; i=j++ * ++j * j++;

未定义的行为:请参阅常见问题解答。 (非正式地说,你以随机顺序更新j三次; 你为什么期望结果有意义?除了它更糟糕 之外。) - Chris" sparqling" Dollin 你服务的对象是谁,你信任谁?

Undefined behaviour: see the FAQ. (Informally speaking, you update j three times in random order; why do you expect the result to make sense? Except it''s worse than that.) -- Chris "sparqling" Dollin "Who do you serve, and who do you trust?"

嗨极客, 请告诉我哪本书给出了C和C ++动态内存管理的完整 详细信息。 Hi geeks, Please tell me which book gives the complete detail of dynamic memory management in C and C++.

更多推荐

意外的结果

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

发布评论

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

>www.elefans.com

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