为什么控制权就转至"否则"部分? [英] Why the control goes in "else" part?
本文介绍了为什么控制权就转至"否则"部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
int a = 8;
if (a==8)
printf("x");
else
printf("y");
虽然 A
等于 8
,它输出是
。
推荐答案
在code就永远版画 X
。如果你的code打印别的东西,那么你在你的问题忽略的重要信息。
The code above always prints x
. If your code prints something else, then you omitted vital information in your question.
要找出哪些可能是,试试这个:
To find out what that might be, try this:
-
插入
和#undef一个
在int类型的= 8;
,以确保不存在一个C preprocessor宏与code弄乱。
Insert
#undef a
before theint a = 8;
to make sure there isn't a C preprocessor macro that messes with the code.
交换的条件,看看 A
真的是你所期望的:
Swap the condition to see if a
is really what you expect:
if( 8 == a )
这个小动作也美元的意外分配错误p $ pvents你(如果(A = 8)
)
This little trick also prevents you from the accidental assignment bug (if( a = 8 )
)
这篇关于为什么控制权就转至"否则"部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文