Why the following function is called thrice

后端 未结 6 1310
轻奢々
轻奢々 2021-01-20 10:45

I had tried to debug but no luck I can\'t understand why the second printf() is call increment() thrice but the first one call twice as expected.

#include &l         


        
6条回答
  •  日久生厌
    2021-01-20 11:32

    Because you tell it so:

    MAX(x, increment())
    

    evaluates to

    ( (x) > (increment()) ? (x) : (increment()) )
    

    and if the condition is not fulfilled, the part after the : is evaluated and thus the function called again.

提交回复
热议问题