[Solved] Different output from macros and function definition [duplicate]


In the macro

#define prod(a,b) ((a>b)?a*a:b*b)

a and b are referenced more than once. So

prod(p1++,q1++)

becomes

(p1++ > q1++) ? p1++*p1++ : q1++*q2++

Note that this is very different than calling the function

prod1(p1++, q1++)

which only increments p1 and q1 once. And does so predictably.

2

solved Different output from macros and function definition [duplicate]