English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2 answers

It's called post-autoincrementation, and it just adds one to b, but only AFTER the line in which b++ occurs is completed.

if you write:
int b = 5;
int c = b++;

c will equal what b was BEFORE b had one added to it. So c will be 5, while b will be 6 after that code is executed.

Furthermore, there is PRE-autoincrementation, where the 1 is added to b BEFORE the rest of the line is executed:
int b = 10;
int c = ++b;

In this case, c = b = 11 after the code is executed, because b is 10, then has 1 added to it, then c is assigned the value of b.

Ok?

2006-12-06 05:47:35 · answer #1 · answered by TankAnswer 4 · 0 0

b++ means to increment b by one. You could just as easily have written b=b+1 or b +=1 .

2006-12-06 04:58:28 · answer #2 · answered by Chris S 5 · 0 0

fedest.com, questions and answers