简体   繁体   中英

What is the difference between + + and direct+ 1 in C or C + +?

like a++ and a+1 , I know that a++ = a = a + 1 , besides this, what's the difference?

The biggest difference is that a+1 is just adding one to the variable a , but what do you do with it:

a = 3;
b = a + 1;

As a result, a still is 3 and b is 4.

But:

a = 3;
b = a++;

As a result, b is 4 but a is also 4 ( a++ means a = a+1 , so a has been changed).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM