C language: y = ((x=a+b),(b+c)) and y = (x=a+b),(b+c) Why are the results different

#include<stdio.h>

int main()
{
    
    
int a=2,b=4,c=6,x,y,q,p;
 y = ((x=a+b),(b+c));
 q = (p=a+b),(b+c);
printf ("%d,%d\n",x,y);
printf ("%d,%d\n",p,q);
return 0;
}

Insert picture description here
The precedence of the comma operator is lower than the equal sign,
so when you use the comma operator, you must add parentheses. For
example, this sentence

 q = (p=a+b),(b+c);

His meaning is
p = a+b;
q = p; the
latter, (b+c) is equivalent to void

Guess you like

Origin blog.csdn.net/helloworld573/article/details/105700590