| |

VerySource

 Forgot password?
 Register
Search
Author: mpc_bywind

Discuss a C language problem

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-13 17:15:02
| Show all posts
Finally, there is such a thing I know very well, but when I answered, I found that there were so many big cows in front, so many steps late
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-15 15:30:01
| Show all posts
Testing is best in specific operating environments
Reply

Use magic Report

0

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-2-16 14:45:01
| Show all posts
This question is only related to the grammar rules of the C language, and has nothing to do with how to implement it!
No matter what c compiler, the result is the same. Otherwise it cannot be called "language"
For: suppose i = 2
printf ("% d,% d", i, i ++); // This case is displayed as: 3,2
printf ("% d,% d", i, ++ i); // This case is displayed as: 3,3
printf ("% d,% d", i ++, i); // This case is displayed as: 2,3
printf ("% d,% d", ++ i, i); // This case is displayed as: 3,3
The results of the first and second sentences are abnormal. It is estimated that you read the wrong result!
printf ("% d,% d", i, i ++); // should show as: 2,2
printf ("% d,% d", i, ++ i); // should show as: 2,3
If it is not that you read it wrong, then you have a problem with the c compiler, please give up

Although C is very flexible, it is not flexible enough to change even the grammar rules!

It is really admirable for the "five bodies to cast their grounds" that the "experts" above have to explain "wrong".
Reply

Use magic Report

0

Threads

1

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-25 12:02:16
| Show all posts
++ is behind, i ++ value is i, i then add 1
Reply

Use magic Report

0

Threads

12

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-3-1 20:45:01
| Show all posts
The master of LS said inexplicably, C did not define the order of expression evaluation, of course, the result should be compiler-related ...
Reply

Use magic Report

0

Threads

17

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 Localhost

Post time: 2020-3-6 17:00:01
| Show all posts
Pushing the stack from right to left is not the same as counting from right to left! !! You still don't need to do anything. Read more books. The "C A Reference Manual" is recommended.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-13 19:30:01
| Show all posts
Do you have to use it this way?
Try to avoid such problems.
Research this,
I think,

not worth
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-13 21:15:01
| Show all posts
Support upstairs and upstairs
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-20 22:15:01
| Show all posts
i = 0

printf ("% d,% d", i, i ++); // 1,0
printf ("% d,% d", i, ++ i); // 1,1
printf ("% d,% d", i ++, i); // 0,0
printf ("% d,% d", ++ i, i); // 1,0
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-17 15:00:01
| Show all posts
This has to do with the compiler! Is the result different for different compilers? . . c Pressure parameters are from right to left. . The remaining high-level languages ​​are pressed from left to right!
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