c - Macro argument with different results -


this question has answer here:

so have been having rather 'unyielding' problem macro call in c program. macro used :

#define macro(x) x*x 

and problem when

printf("%d",macro(3)); 

it displays 9 result (which correct). when pass 3 2+1 follows :

printf("%d",macro(2+1)); 

it strangely displays outcome of 5. can please have me informed why?

printf("%d",macro(2+1)); 

after preprocessing become

printf("%d",2+1*2+1); 

since multiplication has high precidenece on addition, print 5;

to resolve issue have define macro follows

#define macro(x) (x)*(x) 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -