this code is
# include
# define SQ (y) (y) * (y))
Int sq (int y)
{
Return ((y) * (y));
}
Int main ()
{
Int I=1, j=1;
While (i
=5)Printf (" % d \ n ", SQ (i++));
printf("\n");
While (j
=5)Printf (" % d \ n ", sq (j++))
;
printf("\n");
return 0;
}
Why is 1 3 party 5 party SQ in
Hope that they can help me answer the bosses
CodePudding user response:
Because SQ (i++) is equal to
(i++) * (i++)
CodePudding user response:
Your macro definition belong to undefined behaviorThe equivalent of
While (i<{
=5)Printf (" % d \ n ", (i++) * (i++));//macro definition is just your expression, the compiler is different, the result will be different, it is impossible to know the results
}
The function is different
Sq (j++) is equivalent to sq (j), j++; Such a comma expression, the result is knowable
CodePudding user response: