L
lgn
I have test the following program, why the result is not 0 2 4 but 0 2 3?
Can someone tell me why the same macro produce different result? Thanks!
#include <stdio.h>
#define max(a,b) ((a)>(b) ? (a): (b))
test()
{
printf("%d\n", 1);
}
int main(int argc, char* argv[])
{
int a=0, b=0;
printf("%d %d\n", a, b);
max(++a, b);
printf("%d %d\n", a, b);
max(++a, b+10);
printf("%d %d\n", a, b);
}
Can someone tell me why the same macro produce different result? Thanks!
#include <stdio.h>
#define max(a,b) ((a)>(b) ? (a): (b))
test()
{
printf("%d\n", 1);
}
int main(int argc, char* argv[])
{
int a=0, b=0;
printf("%d %d\n", a, b);
max(++a, b);
printf("%d %d\n", a, b);
max(++a, b+10);
printf("%d %d\n", a, b);
}