Difference between pre-increment and post-increment in a loop?

后端 未结 22 1818
暗喜
暗喜 2020-11-21 23:41

Is there a difference in ++i and i++ in a for loop? Is it simply a syntax thing?

22条回答
  •  时光取名叫无心
    2020-11-22 00:35

    It boggles my mind why so may people write the increment expression in for-loop as i++.

    In a for-loop, when the 3rd component is a simple increment statement, as in

    for (i=0; i

    or

    for (i=0; i

    there is no difference in the resulting executions.

提交回复
热议问题