| |

VerySource

 Forgot password?
 Register
Search
View: 496|Reply: 2

The difference between m = ++ i and m = i ++

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-19 14:00:01
| Show all posts |Read mode
I just learned C, I am self-taught, many places are unclear
I encountered such a code while reading a book today, please help me explain

main ()
{
 int i, j, m, n;

 i = 8;

 j = 10;

 m = ++ i;

 n = j ++;

 printf ("% d,% d,% d,% d", i, j, m, n);
}
The output is 9, 11, 9, 10
I would like to ask everyone what is the difference between m = ++ i and m = i ++
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-26 08:45:01
| Show all posts
m = ++ i <=> i ++; m = i
m = i ++ <=> m = i; i ++
The order is different!
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-4-26 14:15:01
| Show all posts
Thank you you reminded me I understand
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list