what does x— or x++ do here?

后端 未结 7 1252
猫巷女王i
猫巷女王i 2021-01-23 01:53

it is a silly Q for most of u - i know - but i one of the beginner here, and I can not understand why the output in here are 12 what does this (x--) do to the resu

7条回答
  •  孤独总比滥情好
    2021-01-23 02:37

    Example:

    x = 7;
    y = --x; /* prefix -- */
    

    Here y = 6 (--x reduce x by 1)

    y = x--; /* postfix -- */
    

    Here y = 6 (x-- use first the value of x in the expression and then reduce x by 1)

提交回复
热议问题