Home > Back-end >  C language small white problem
C language small white problem

Time:11-18

Today I try to write the following code
Int a=2, b=4, c=6;
Y=(x=a + b), (b + c);
Printf (" y=% d, x=% d \ n ", y, x);
Why is the execution result y=6? I don't understand, shouldn't be? X) y, d/y=printf (b + x=y=a=int the not

CodePudding user response:

 # include & lt; Stdio. H> 

Int main (void)
{
int x, y;
Int a=2, b=4, c=6;
Y=((x=a + b), (b + c));
Printf (" y=% d, x=% d \ n ", y, x);

return 0;
}

This value is y=10, but compare the expression of what don't you?

For example:

 int x=5, y; 

X, please? y?

Such expressions may be you understand, because is to initialize x 5, y no initialization;

You could be understood as a comma expression, but the original poster y=(x=a + b), (b + c); Y at the back of the expression is a whole? And the above code is quite a ()?
  • Related