LoginSignup
14
10

More than 5 years have passed since last update.

i++と++iの違い

Last updated at Posted at 2016-04-10

++iは返り値としてインクリメント後の値を返す

 i = 1;
 j = ++i;
 (i is 2, j is 2)

i++は返り値としてインクリメント前の値を返す

 i = 1;
 j = i++;
 (i is 2, j is 1)

参考: What is the difference between ++i and i++

14
10
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
10