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