I wrote the following code to test MACRO functions:
#define err_exit(a, b) {fprintf(stdout,"%s\n",(a)); return (b); }
int func1(int a){
if(a<50)
err_exit("less than 50", a);
if(a>50)
err_exit("greater than 50", a);
return 0;
}
int main() {
fprintf(stdout, "\npop\n%d\n",func1(30));
return 0;
}
And the output is:
less than 50
pop
30
But I was expecting this output:
pop
less than 50
30
Why is the text appearing before the pop
? the function func1()
is called after it!
How do macro replace instructions in the main code?