C: What is the difference between ++i and i++?

前端 未结 21 2067
伪装坚强ぢ
伪装坚强ぢ 2020-11-21 06:04

In C, what is the difference between using ++i and i++, and which should be used in the incrementation block of a for loop?

21条回答
  •  甜味超标
    2020-11-21 06:17

    i++: In this scenario first the value is assigned and then increment happens.

    ++i: In this scenario first the increment is done and then value is assigned

    Below is the image visualization and also here is a nice practical video which demonstrates the same.

    enter image description here

提交回复
热议问题