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:
Insert
#undef a
before theint a = 8;
to make sure there isn’t a C preprocessor macro that messes with the code.Swap the condition to see if
a
is really what you expect:if( 8 == a )
This little trick also prevents you from the accidental assignment bug (
if( a = 8 )
)