I was told C preprocessor "#define arg1 agr2" would do a text replacement - arg1 string with arg2....
I wrote a few lines of code as follows:
#include "stdio.h"
#define PRNT(v,x) printf("x = %v\n", x)
main() {
int i = 5;
PRNT(d, i);
return 0;
}
I expected that after the preprocessing step, the program would become
main() {
int i = 5;
printf("i = %d\n", i);
return 0;
}
and it should print
i = 5
but the preprocessor #define did not work as expected! - the program printed
i = %v
???? Why does C behave that way? What didn't I understand? Please help
Thanks
EE02IU
P.S. I used Borland C++ 4.52