loop's counter i as I++ vs. i+1 as position in an array

前端 未结 7 1400
甜味超标
甜味超标 2021-01-13 23:25

I\'ve made a loop with i as it\'s counter variable.
Inside that loop I\'m comparing cells of an array.
I\'m wondering what\'s the difference between array[i++] (or a

7条回答
  •  有刺的猬
    2021-01-13 23:30

    array[i++] will give you the same as array[i] and then increment i. array[++i] will give you the same as array[i+1] and increment i. array[i+1] won't actually change the value of i.

提交回复
热议问题