Home > Back-end >  A a C language
A a C language

Time:10-07

Why the same conditions in the printf can appear different results,

Expression -- the value of a is not a.?
Expression -- after a value also is the a - 1 the value of

CodePudding user response:

Printf from after the forward calculation, which is a - come first, and then - a

CodePudding user response:

1/f, reference and 蘤 old crepe response:
printf from after the forward calculation, which is a - come first, and then - a

Educated, thank you bosses

CodePudding user response:

Even if there is order, and don't line of the same variable + + for many times,,,, after all, you have to think about the order, rather than a moment away.

CodePudding user response:

1/f, reference and 蘤 old crepe response:
printf from after the forward calculation, which is a - come first, and then - a
wrong
It is undefined behavior
No provisions to from the back forward

CodePudding user response:

reference ggglivw reply: 3/f
even if there is order, don't be a line of the same variable multiple + +, -, after all you have to think about the order, rather than the past moment.

This is a choice, I don't write their own must be a line of writing much + + -

CodePudding user response:

reference 4 floor lin5161678 response:
Quote: 1/f, reference and 蘤 old crepe response:

Printf from after the forward calculation, which is a - come first, and then - a
wrong
It is undefined behavior
No provisions to from forward after


To calculate the value of the expression from right to left (stack), then print the value of the expression from left to right (out of the stack)

Don't go to the source code, you check, temporarily didn't find

CodePudding user response:

reference 4 floor lin5161678 response:
Quote: 1/f, reference and 蘤 old crepe response:

Printf from after the forward calculation, which is a - come first, and then - a
wrong
It is undefined behavior
No provisions to from forward after

That is why

CodePudding user response:

refer to 6th floor and 蘤 old crepe reply:
Quote: refer to 4th floor lin5161678 response:

Quote: 1/f, reference and 蘤 old crepe reply:

Printf from after the forward calculation, which is a - come first, and then - a
wrong
It is undefined behavior
No provisions to from forward after


To calculate the value of the expression from right to left (stack), then print the value of the expression from left to right (out of the stack)

Don't go to the source code, you check, temporarily didn't find counterexamples


CodePudding user response:

refer to the eighth floor lin5161678 response:
Quote: refer to the 6th floor and 蘤 old crepe reply:

Quote: refer to 4th floor lin5161678 response:

Quote: 1/f, reference and 蘤 old crepe reply:

Printf from after the forward calculation, which is a - come first, and then - a
wrong
It is undefined behavior
No provisions to from forward after


To calculate the value of the expression from right to left (stack), then print the value of the expression from left to right (out of the stack)

Don't go to the source code, you check, temporarily didn't find counterexamples




Values do have a problem, or can't block the undefined behavior here, but calculated from right to left or right, so the next time, do not have to write

CodePudding user response:

with reference to the tenth floor 蘤 old crepe response:
but calculated from right to left or right

How do you see from right to left is right??

CodePudding user response:

with reference to the tenth floor 蘤 old crepe response:
Quote: refer to the eighth floor lin5161678 response:

Quote: refer to the 6th floor and 蘤 old crepe reply:

Quote: refer to 4th floor lin5161678 response:

Quote: 1/f, reference and 蘤 old crepe reply:

Printf from after the forward calculation, which is a - come first, and then - a
wrong
It is undefined behavior
No provisions to from forward after


To calculate the value of the expression from right to left (stack), then print the value of the expression from left to right (out of the stack)

Don't go to the source code, you check, temporarily didn't find counterexamples




Values do have a problem, or can't block the undefined behavior here, but calculated from right to left or right, so the next time don't write the

C compiler online

CodePudding user response:

11 references lin5161678 response:
Quote: with reference to the tenth floor 蘤 old crepe response:

But calculated from right to left or right

How do you see from right to left is right??


Ok, are you the compiler tried the printf (" % d % d ", a, +), the result is 0, 0

It looks can be overturned thoroughly, should be determined by the pressure of stack sequence, from which to which cannot be determined, Internet basic full execution order from right to left, just checked from left to right, discovered the related account, learned, 3 q



CodePudding user response:

You can have a try, the different compiler, the results would be different, don't write in the output and the expected answer yes, personal feel there is no need to entanglements this thing

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related