solution C Puzzle #5

Output:
12
f(1,2)
Reason:
the # operator stringizes its operand, i.e. it puts double quotes
around it.
The ## operator 'glues' its operands together.

The preprocessor expands macro definitions in the text.
It keeps expanding macros as long as it finds any; to block
recursion 
it won't expand a macro that is being expanded already.
in the first printf(), firstly, it is replacing h(f(1,2)) by
g(f(1,2)), and then immediately in the same pass, it calculated
its argument i.e. f(1,2), resulting in "12". Thus getting g("12")
in place of h(f(1,2)). This g("12") results in a string "12".

In short, in first printf()
h(f(1,2)) >> g("12") >> "12"

In the second printf(),
g(f(1,2)) >> "f(1,2)"

No comments:

Post a Comment