Message from C, C++ talks

July 2019

— I=0 is false, because it returns 0, and 0 is the only integral that casts to false

— Can you explain what exactly happens there, why there are 2,1,0?

— Because I don't remember ever seeing such syntax

— I= 0 means assignment of 0 in a variable named i.
Is
int i=0;
if i


Same as
int i=0;

— 

I=(2,1,0) evaluates to i= 0 bcoz associativity of paranthesis is from left to right .
There is nothing wrong in this syntax

— Comma operator

— Yep
but you can do
int a,b,c;
a = b = c = 5;
it will execute c = 5, the result will be 5 and it will be assigned to b, and the result of this will again be 5 and then it will be assigned to a.
in your case 0 is assigned and result (again 0) is casted into bool

Message permanent page

— So it's like "execute and forget about it"? in this case 2 and 1 will be just skipped?

— So what is if(i=(1,2,0)) ?

— C

— If Statement

— Do you send these type of questions daily?

— No...I get these questions in my uni's coding club group ... I was having a doubt today

— The answer is C

— I know that pretty well. I was asking for the explanation I guess